一开始,当我将rails generate controller welcome homepage
运行到项目的目录中时,该命令正常工作并生成app/controllers/welcome_controller.rb
和路由get welcome/homepage
User1@My-Machine:~/MyProject$ rails generate controller welcome homepage
/home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/app_rails_loader.rb:39: warning: Insecure world writable dir /home/User1/.rbenv/versions in PATH, mode 040777
create app/controllers/welcome_controller.rb
route get 'welcome/homepage'
之后,该命令会遇到以下错误:
/home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:98:in `binread': Input/output error @ rb_sysopen - /home/User1/MyProject/config/routes.rb (Errno::EIO)
后跟一个文件列表。
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:98:in `replace!'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:59:in `invoke!'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:30:in `insert_into_file'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/generators/actions.rb:224:in `block in route'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:194:in `block in in_root'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:184:in `block in inside'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:128:in `chdir'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/2.3.0/fileutils.rb:128:in `cd'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:184:in `inside'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:194:in `in_root'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/generators/actions.rb:223:in `route'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/generators/rails/controller/controller_generator.rb:16:in `block in add_routes'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/generators/rails/controller/controller_generator.rb:15:in `reverse_each'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/generators/rails/controller/controller_generator.rb:15:in `add_routes'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/generators.rb:157:in `invoke'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/generate.rb:13:in `<top (required)>'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:123:in `require_command!'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:130:in `generate_or_destroy'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:50:in `generate'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/User1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
有谁知道如何解决这个问题?
答案 0 :(得分:0)
这个答案有点像拼写,但我对当前版本的WSL的经验是,rbenv在WSL中运行有问题,而RVM似乎运行正常。原始问题听起来像是你可能正在从Windows界面移动linux特定文件,如/ home / user / file(来自appdata区域) - 绝对是don't do that. Only manipulate those files from bash, as corruption and oddities will occur。
不确定为什么在您的设置中没有正确创建或看到的东西,但总的来说,这里有什么对我有用:
使用RVM,在this guy的帮助下,我得出结论,我需要
bundle config --delete bin
rake rails:update:bin
git add bin
并使用
bash --login
从Windows登录交互式版本的bash。
我已成功创建并处理已装载空间中Bash和Windows的项目,即/mnt/c/Users/Tim/Desktop/railsapp
我从bash运行生成器和诸如此类的东西,但是在Windows中从Sublime编辑文件的内容。
祝你好运!