In the beginning, when I run rails generate controller welcome homepage
into my project's dir, the command works OK and produces the app/controllers/welcome_controller.rb
and route 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'
immediately after that, the command runs into the following error:
/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)
followed by a list of files.
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>'
Does anyone know how this can be resolved?
This answer is a bit of a copout, but my experience with the current versions of WSL is that rbenv has issues running in WSL, wheras RVM seems to work okay. The original question sounds like you may be moving linux specific files like /home/user/file (from the appdata area) from the Windows interface -- definitely don't do that. Only manipulate those files from bash, as corruption and oddities will occur .
Not sure why things aren't being created or seen correctly in your setup, but in general, here's what has worked for me:
Using RVM, and with the help of this guy I came to the conclusion that I need to
bundle config --delete bin
rake rails:update:bin
git add bin
and use
bash --login
to log into the interactive version of bash from Windows.
I've been successfully creating and working with projects from both Bash and Windows in the mounted space, ie /mnt/c/Users/Tim/Desktop/railsapp
I run generators and whatnot from bash, but edit the content of the files from Sublime in Windows.
Good luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.