首页 > 解决方案 > 尝试在 Bundle Install [Rails 5.1.3, Ruby 2.3.3] 上写入 C:/Users/REMOTE~1/AppData/ 时出错

问题描述

为此一直挠头好几个小时。

突然之间,我无法在我的项目上运行命令 bundle update 和 bundle install 。

我收到以下错误:

尝试写入时出错 C:/Users/REMOTE~1/AppData/Local/Temp/bundler-compact-index-20181216-9268-sd4t9f/versions。您可能需要授予该路径的写入权限。

1.)该路径和用户不存在

2.)我查看了环境变量,它们都指向我的用户

3.)这与我的项目无关,因为即使我尝试创建一个新的 rails 项目,rails new 命令的一部分也会运行“bundle install”,因此也会失败。

4.) 我是管理员,所以我不明白为什么我没有完全的读/写权限。

额外的信息:

捆绑器环境:

## Environment

```
Bundler       1.17.2
  Platforms   ruby, x86-mingw32
Ruby          2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
  Full Path   C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe
  Config Dir  C:/ProgramData
RubyGems      2.5.2
  Gem Home    C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0
  Gem Path    C:/Users/correctuser/.gem/ruby/2.3.0;C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0
  User Path   C:/Users/correctuser/.gem/ruby/2.3.0
  Bin Dir     C:/RailsInstaller/Ruby2.3.3/bin
Tools
  Git         2.19.1.windows.1
  RVM         not installed
  rbenv       not installed
  chruby      not installed
```

## Bundler Build Metadata

```
Built At          2018-12-11
Git SHA           43e950846
Released Version  true

```

宝石环境:

RubyGems Environment:
 - RUBYGEMS VERSION: 2.5.2
  - RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0
  - USER INSTALLATION DIRECTORY: C:/Users/correctuser/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/RailsInstaller/Ruby2.3.3/bin
  - SPEC CACHE DIRECTORY: C:/Users/correctuser/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0
     - C:/Users/correctuser/.gem/ruby/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - C:\Program Files\ConEmu\ConEmu\Scripts
     - C:\Program Files\ConEmu
     - C:\Program Files\ConEmu\ConEmu
     - C:\Program Files (x86)\Common Files\Oracle\Java\javapath
     - C:\windows\system32
     - C:\windows
     - C:\windows\System32\Wbem
     - C:\windows\System32\WindowsPowerShell\v1.0\
     - C:\windows\System32\OpenSSH\
     - C:\Program Files\Git\cmd
     - C:\Program Files\PuTTY\
     - C:\Program Files\nodejs\
     - C:\Program Files (x86)\QuickTime\QTSystem\
     - C:\RailsInstaller\Git\cmd
     - C:\RailsInstaller\Ruby2.3.3\bin
     - C:\Users\correctuser\AppData\Local\Microsoft\WindowsApps
     - C:\Users\correctuser\AppData\Roaming\npm
     - C:\Program Files\heroku\bin
     - C:\Program Files\JetBrains\RubyMine 2018.3\bin 

标签: rubyruby-on-rails-5bundler

解决方案


经过 3 天的修补并试图找到解决方案后,我想出了以下内容。

1.) 正如@anothermh 所提到的,最好在适用于 Linux 的 Windows 子系统上安装 Ruby 在 WSL(适用于 Linux 的 Windows 子系统)上安装 Ruby以避免这种情况。

2.) 对于仍然想在他们的 Windows 系统上继续使用 Ruby 的人。

当您的捆绑程序 ruby​​gems 副本损坏并缓存到您的系统中时,会发生此错误。

我通过删除 C:/users/my_user/.bundle 中的文件夹 .bundle 解决了这个问题

重新安装 bundler,这个错误就会消失,你的 gems 会像往常一样编译和安装。


推荐阅读