运行bundle install时出现此错误:
Errno::EPERM: Operation not permitted @ dir_s_rmdir - /home/rbtlong/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/versions
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb:50:in `unlink'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb:50:in `delete'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb:50:in `update'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb:64:in `update'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb:55:in `update_and_parse_checksums!'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/fetcher/compact_index.rb:65:in `available?'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/fetcher/compact_index.rb:15:in `call'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/fetcher/compact_index.rb:15:in `block in compact_index_request'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/fetcher.rb:154:in `use_api'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/source/rubygems.rb:331:in `block in api_fetchers'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/source/rubygems.rb:331:in `select'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/source/rubygems.rb:331:in `api_fetchers'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/source/rubygems.rb:336:in `block in remote_specs'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/index.rb:10:in `build'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/source/rubygems.rb:335:in `remote_specs'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/source/rubygems.rb:82:in `specs'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/lazy_specification.rb:56:in `__materialize__'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/spec_set.rb:91:in `block in materialize'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/spec_set.rb:88:in `map!'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/spec_set.rb:88:in `materialize'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/definition.rb:140:in `specs'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/definition.rb:129:in `resolve_remotely!'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/installer.rb:195:in `resolve_if_need'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/installer.rb:70:in `run'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/installer.rb:22:in `install'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/cli/install.rb:102:in `run'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/cli.rb:175:in `install'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/cli.rb:11:in `start'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/exe/bundle:27:in `block in <top (required)>'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
/home/rbtlong/.rvm/gems/ruby-2.2.3/gems/bundler-1.12.3/exe/bundle:19:in `<top (required)>'
/home/rbtlong/.rvm/gems/ruby-2.2.3/bin/bundle:23:in `load'
/home/rbtlong/.rvm/gems/ruby-2.2.3/bin/bundle:23:in `<main>'
/home/rbtlong/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
/home/rbtlong/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'
环境:
Bundler 1.12.3
Rubygems 2.4.8
Ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
GEM_HOME /home/rbtlong/.rvm/gems/ruby-2.2.3
GEM_PATH /home/rbtlong/.rvm/gems/ruby-2.2.3:/home/rbtlong/.rvm/gems/ruby-2.2.3@global
RVM 1.27.0 (latest)
Git 2.5.0
rubygems-bundler (1.4.4)
Bundler设置:
orig_path
Set via BUNDLE_ORIG_PATH: "/home/rbtlong/.rvm/gems/ruby-2.2.3/bin:/home/rbtlong/.rvm/gems/ruby-2.2.3@global/bin:/home/rbtlong/.rvm/rubies/ruby-2.2.3/bin:/home/rbtlong/.rvm/bin:/home/rbtlong/.dnx/runtimes/dnx-mono.1.0.0-rc1-update1/bin:/home/rbtlong/.dnx/bin:/usr/local/heroku/bin:/home/rbtlong/.rbenv/plugins/ruby-build/bin:/home/rbtlong/.rbenv/shims:/home/rbtlong/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
orig_gem_path
Set via BUNDLE_ORIG_GEM_PATH: "/home/rbtlong/.rvm/gems/ruby-2.2.3:/home/rbtlong/.rvm/gems/ruby-2.2.3@global"
答案 0 :(得分:3)
在我做完之后它起作用了......
sudo chmod 1777 -R /home/rbtlong/.bundle/cache/compact_index
和
sudo chmod 1777 -R /tmp
答案 1 :(得分:3)
对我而言,它仅适用于777模式。所以我做了
sudo chmod 777 -R /home/<username>/.bundle/cache/compact_index
和
sudo chmod 777 -R /tmp
解释原因:它与Unix权限有关。您不能以超级用户(root)身份运行bundle,但bundle正在尝试写入用户必须是超级用户才能在其上写入的文件夹。 chmod 777 -R
是一个命令,基本上说任何人(不仅是超级用户)都可以读取或写入该文件夹,对于没有-R
参数的文件,你可以做同样的事情(这意味着递归)。
答案 2 :(得分:1)
我必须先运行:
sudo rm -rf /home/<username>/.bundle/cache/compact_index/*
然后
sudo chmod 1777 -R /home/rbtlong/.bundle/cache/compact_index
sudo chmod 1777 -R /tmp
答案 3 :(得分:0)
我不知道您是否通过以上某个答案找出了问题,但我遇到了同样的问题,并从this question发现Dir.foreach
返回'.'
和{ {1}}作为可枚举的一部分,您不能也不应该删除当前和父目录
答案 4 :(得分:0)
我通过关闭以管理员身份打开的Docker终端并在普通用户终端中运行服务器来解决了我的问题。不需要运行任何命令。
我在docker启用的Linux环境中运行此程序,因此,该解决方案可能对使用linux或docker的人有所帮助。