簡體   English   中英

Ruby On Rails,錯誤運行命令“ rails generate controller”,輸入/輸出錯誤@ rb_sysopen,(Errno :: EIO)

[英]Ruby On Rails, Error running command “rails generate controller”, Input/output error @ rb_sysopen, (Errno::EIO)

開始時,當我運行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>'

有人知道如何解決嗎?

這個答案有點不合時宜,但是我對當前版本的WSL的經驗是rbenv在WSL中運行時有問題,而RVM似乎可以正常工作。 最初的問題聽起來像是您可能正在從Windows界面移動linux特定文件,例如/ home / user / file(來自appdata區域)-絕對不要這樣做。 僅從bash操作這些文件,因為會發生損壞和奇怪的情況

不確定為什么無法在您的設置中創建或正確顯示事物,但是總的來說,這對我有用:

使用RVM,並在這個家伙的幫助下,我得出結論,我需要

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編輯文件的內容。

祝好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM