编辑:请参阅下面更新的部分,其中我根据给定的解决方案建议修改了代码
在我的win7机器上,我用的是带有宅基地的流浪汉。我想安装一些gulp软件包,例如gulp,它不能工作,因为我得到了下面添加的错误。
在#npm频道进行了一些研究和讨论之后,我在这里暗示了这个问题:
根据该条目,windows用户在使用迷航器时仍然存在问题,因为主机和来宾计算机之间的共享文件夹最大字符限制为260个字符,这一直是windows开发中的一个主要问题。
一个解决办法似乎是改变流浪汉的档案和与它一起的规定。
以下是初始错误:
vagrant@homestead:~/Code/Wordpress/wp-content/themes/expimo$ gulp uncss
[10:51:07~/Code/Wordpress/wp-content/themes/expimo/gulpfile.js
[10:51:07] Starting 'uncss'...
/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/bluebird/js/main/async.js:43
fn = function () { throw arg; };
^
TypeError: Bad argument
at TypeError (native)
at ChildProcess.spawn (child_process.js:1136:26)
at /home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/lib/spawn.js:82:38
at init (/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePro
at new Promise (/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:27:53)
at Function.promise (/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/when.js:97:10)
at startPhantom (/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/lib/spawn.js:58:25)
at tryCatchReject (/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:845:30)
at runContinuation1 (/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:804:4)
at Fulfilled.when (/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:592:4)
at Pending.run (/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:483:13)
at Scheduler._drain (/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/Scheduler.js:62:19)
at Scheduler.drain (/home/vagrant/Code/Wordpress/wp-content/themes/expimo/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/Scheduler.js:27:9)
at process._tickCallback (node.js:355:11)正如我从条目中了解到的,我是否必须修改我的Vagrantfile,甚至可能添加一些条款?
这是我当前的默认Vagrantfile文件,该文件是通过“宅基地”添加的:
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION = "2"
homesteadYamlPath = File.expand_path("~/.homestead/Homestead.yaml")
afterScriptPath = File.expand_path("~/.homestead/after.sh")
aliasesPath = File.expand_path("~/.homestead/aliases")
require_relative 'scripts/homestead.rb'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exists? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
end
Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
if File.exists? afterScriptPath then
config.vm.provision "shell", path: afterScriptPath
end
end显然,我必须插入以下修改:https://github.com/renobit/vagrant-node-env/commit/bdf15f2f301e2b1660b839875e34f172ea8be227
在这个Vagrantfile文件中,使宅基地正常工作。
由于我刚开始使用流浪语,我的知识非常有限,因此我欢迎任何我能在这个话题上得到的帮助。提前谢谢你。
更新
更新大卫·迈尔斯的建议:
我根据大卫·迈尔斯的建议修改了我的Vagrantfile文件,但没有结果:
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")
homesteadYamlPath = confDir + "/Homestead.yaml"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"
require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exists? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
end
# this should be inserted right before the "Homestead.configure()" line
config.vm.provider "virtualbox" do |v, override|
if Vagrant::Util::Platform.windows?
override.vm.synced_folder "./Code", "/home/vagrant/Code", disabled: true
v.customize ["sharedfolder", "add", :id, "--name", "Code", "--hostpath", (("//?/" + File.dirname(__FILE__) + "/Code").gsub("/","\\"))]
override.vm.provision :shell, inline: "mkdir -p /home/vagrant/Code"
override.vm.provision :shell, inline: "mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` Code /home/vagrant/Code", run: "always"
else
override.vm.synced_folder "./Code", "/home/vagrant/Code"
end
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/Code", "1"]
end
# this should be inserted right before the "Homestead.configure()" line
Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
if File.exists? afterScriptPath then
config.vm.provision "shell", path: afterScriptPath
end
end我还注释了您在我的Homestead.yaml文件中指出的三行:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
# folders:
# - map: ~/Code
# to: /home/vagrant/Code
sites:
- map: expimo.app
to: /home/vagrant/Code/Wordpress
- map: laravel.app
to: /home/vagrant/Code/laravel/public
databases:
- homestead
variables:
- key: APP_ENV
value: local不幸的是,我得到了错误消息:
没有指定的输入文件,因为URI似乎没有定向到正确的文件夹。
如果我在我的homestead.yaml文件中再次取消对这三行的注释,并保留修改后的Vagrantfile,当我试图通过"npm -保存-dev“安装gulp时,我会得到相同的错误。
我接下来该怎么办?
发布于 2015-05-07 07:24:36
是我实现了你提到的那个修复程序。:)
我个人还没有遇到这个问题,但我想我知道你需要做什么。首先,您需要在Homestead.yaml文件中注释掉这些行:
folders
- map: ~/Code
to: /home/vagrant/Code接下来,您需要将此配置添加到您的Vagrantfile中
# this should be inserted right before the "Homestead.configure()" line
config.vm.provider "virtualbox" do |v, override|
if Vagrant::Util::Platform.windows?
override.vm.synced_folder "./Code", "/home/vagrant/Code", disabled: true
v.customize ["sharedfolder", "add", :id, "--name", "Code", "--hostpath", (("//?/" + File.dirname(__FILE__) + "/Code").gsub("/","\\"))]
override.vm.provision :shell, inline: "mkdir -p /home/vagrant/Code"
override.vm.provision :shell, inline: "mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` Code /home/vagrant/Code", run: "always"
else
override.vm.synced_folder "./Code", "/home/vagrant/Code"
end
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/Code", "1"]
end
# this should be inserted right before the "Homestead.configure()" line请注意前一个块中的注释;您需要确保它是在运行家庭宅基地配置之前插入的。
注意:这个脚本假设您共享一个名为"Code“的目录,该目录位于与此Vagrantfile相同的目录中。
发布于 2015-06-10 15:55:37
我在Windows上提供了一个完整的指南/演练,解决了所有这些问题(以及其他问题,比如winnfsd/etc的缓存问题)和Laravel 5& Lumen的解决方案。我将保持这个要点的最新(并不断提高它的可读性)。你可以在这里找到要点:https://gist.github.com/prograhammer/9493ee04f30dd74e121b
在Gist中,我必须向David Myers解决方案添加几个步骤:
在第495-510行附近更新C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.2\plugins\providers\virtualbox\driver\version_4_3.rb,用'\\\\?\\' + folder[:hostpath].gsub(/[\/\\]/,'\\')]替换行folder[:hostpath]
更新C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.2\lib\vagrant\util\platform.rb并注释掉本节的大部分内容:
# This expands the path and ensures proper casing of each part
# of the path.
def fs_real_path(path, **opts)
#path = Pathname.new(File.expand_path(path))
#
# if path.exist? && !fs_case_sensitive?
# # Build up all the parts of the path
# original = []
# while !path.root?
# original.unshift(path.basename.to_s)
# path = path.parent
# end
#
# # Traverse each part and join it into the resulting path
# original.each do |single|
# Dir.entries(path).each do |entry|
# if entry.downcase == single.encode('filesystem').downcase
# path = path.join(entry)
# end
# end
# end
#end
#
# if windows?
# # Fix the drive letter to be uppercase.
# path = path.to_s
# if path[1] == ":"
# path[0] = path[0].upcase
# end
#
# path = Pathname.new(path)
#end
path
end现在流浪汉起来。
https://stackoverflow.com/questions/30090691
复制相似问题