如何解决不同 gem 依赖项之间的冲突

如何解决不同 gem 依赖项之间的冲突

让我们看看是否有人可以帮助我,我不知道自己在做什么。

该服务器是 debian 8.4,已完全更新。

我还使用“gem update”更新了宝石,所有可能的错误和警告都已修复。

我正在安装 redmine_git_hosting,发生了以下情况:

root@esplx345:/usr/share/redmine# bundle install --without development test
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break
this application for all non-root users on this machine.
Warning: this Gemfile contains multiple primary sources. Using `source` more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run `bundle config disable_multisource true`.
Your Gemfile lists the gem redcarpet (~> 3.3.2) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Fetching https://github.com/jbox-web/gitolite-rugged.git
Fetching https://github.com/jbox-web/grack.git
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "rack":
  In snapshot (Gemfile.lock):
    rack (= 1.5.5)

  In Gemfile:
    rails (~> 4.1.4) was resolved to 4.1.15, which depends on
      actionpack (= 4.1.15) was resolved to 4.1.15, which depends on
        rack (~> 1.5.2)

    gitlab-grack was resolved to 2.0.0.pre, which depends on
      rack (~> 1.4.1)

    rack-openid was resolved to 1.4.2, which depends on
      rack (>= 1.1.0)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
root@esplx345:/usr/share/redmine#

我已经在 Google 上搜索过并尝试了很多方法,但似乎没有任何效果。

我的系统上有以下精华:

root@esplx345:/usr/share/redmine# gem update
Updating installed gems
Nothing to update
root@esplx345:/usr/share/redmine# gem list

*** LOCAL GEMS ***

actionmailer (4.2.6, 4.1.15, 4.1.8)
actionpack (4.2.6, 4.1.15, 4.1.8)
actionpack-action_caching (1.1.1)
actionview (4.2.6, 4.1.15, 4.1.8)
activejob (4.2.6)
activemodel (4.2.6, 4.1.15, 4.1.8)
activerecord (4.2.6, 4.1.15, 4.1.8)
activesupport (4.2.6, 4.1.15, 4.1.8)
arel (7.0.0, 6.0.3, 5.0.1.20140414130214)
atomic (1.1.99, 1.1.16)
awesome_nested_set (3.0.3, 3.0.0)
bigdecimal (1.2.7, default: 1.2.4)
builder (3.2.2)
bundler (1.11.2, 1.7.4)
celluloid (0.17.3, 0.15.2)
celluloid-essentials (0.20.5)
celluloid-extras (0.20.5)
celluloid-fsm (0.20.5)
celluloid-pool (0.20.5)
celluloid-supervision (0.20.5)
coderay (1.1.1, 1.1.0)
coffee-rails (4.1.1, 4.0.1)
coffee-script (2.4.1, 2.2.0)
coffee-script-source (1.10.0, 1.3.3)
concurrent-ruby (1.0.1)
erubis (2.7.0)
eventmachine (1.2.0.1, 1.0.3)
execjs (2.6.0, 2.2.1)
fcgi (0.9.2.1)
ffi (1.9.10, 1.9.6)
gitlab-grack (2.0.2)
globalid (0.3.6)
hike (2.1.3, 1.2.1)
hitimes (1.2.3)
i18n (0.7.0, 0.6.9)
io-console (0.4.5, default: 0.4.2)
jbuilder (2.4.1, 2.1.3)
jquery-rails (4.1.1, 3.1.4, 3.1.2)
json (1.8.3, default: 1.8.1)
listen (3.0.6, 2.4.0)
loofah (2.0.3)
mail (2.6.4, 2.6.1)
mime-types (3.0, 1.25)
mime-types-data (3.2016.0221)
mini_portile2 (2.1.0, 2.0.0)
minitest (5.8.4, 5.4.2, default: 4.7.5)
multi_json (1.11.2, 1.10.1)
mysql2 (0.4.3, 0.3.20, 0.3.16)
net-http-persistent (2.9.4, 2.9)
net-ldap (0.14.0, 0.8.0)
nokogiri (1.6.7.2)
oj (2.15.0, 2.10.3)
pkg-config (1.1.7)
polyglot (0.3.5, 0.3.4)
power_assert (0.2.7)
protected_attributes (1.1.3, 1.0.8)
psych (2.0.17, default: 2.0.5)
rack (1.6.4, 1.5.5, 1.5.2)
rack-openid (1.4.2)
rack-test (0.6.3, 0.6.2)
rails (4.2.6, 4.1.15, 4.1.8)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.7)
rails-html-sanitizer (1.0.3)
railties (4.2.6, 4.1.15, 4.1.8)
rake (11.1.2, 10.3.2, default: 10.1.0)
rb-fsevent (0.9.7)
rb-inotify (0.9.7, 0.9.5)
rdoc (4.2.2, default: 4.1.0)
redcarpet (3.3.4, 3.1.2)
request_store (1.3.1, 1.1.0)
rmagick (2.15.4, 2.13.2)
ruby-openid (2.7.0, 2.5.0)
rubygems-update (2.6.3)
sass (3.4.22, 3.4.6)
sass-rails (5.0.4, 4.0.3)
sdoc (0.4.1)
spring (1.7.1, 1.1.3)
sprockets (3.6.0, 2.12.3)
sprockets-rails (3.0.4, 2.3.3, 2.1.3)
sqlite3 (1.3.11, 1.3.9)
test-unit (3.1.8, default: 2.1.5.0)
thor (0.19.1)
thread_safe (0.3.5, 0.3.3)
tilt (2.0.2, 1.4.1)
timers (4.1.1, 1.1.0)
treetop (1.6.5, 1.4.15)
turbolinks (2.5.3, 2.2.2)
tzinfo (1.2.2, 1.1.0)
uglifier (3.0.0, 2.5.3)
will_paginate (3.1.0)
yajl-ruby (1.2.1, 1.2.0)
root@esplx345:/usr/share/redmine#

非常感谢您的帮助。

答案1

当您拥有不同 Ruby 版本或 Rails 的不同项目时,使用 RVM 是一个很好的策略,但我通常只删除 Gemfile.lock 并运行bundle install,一切就正常运行。

答案2

我使用了 RVM

说明可在此处找到 =>http://redmine-git-hosting.io/how-to/install-redmine/#step-2-install-rvm

复制粘贴,以防它消失。

(step 2) Install RVM

Ruby Version Manager (RVM) is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

root# su - redmine
redmine$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
redmine$ curl -sSL https://get.rvm.io | bash -s stable
Be sure to have this in /home/redmine/.profile :

# Set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
  PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes rvm bin if it exists
if [ -d "$HOME/.rvm/bin" ] ; then
  PATH="$PATH:$HOME/.rvm/bin"
fi

if [ -s "$HOME/.rvm/scripts/rvm" ] ; then
  source "$HOME/.rvm/scripts/rvm"
fi

if [ -s "$HOME/.rvm/scripts/completion" ] ; then
  source "$HOME/.rvm/scripts/completion"
fi
Now you should logout from Redmine user with exit then ‘relogin’ with su - redmine to reload env vars properly.

相关内容