iBug
iBug

Reputation: 37307

Bundler can't resolve the correct (dependent) version of a gem that's manually installed and removed

I have absolutely never written any Ruby programs. I'm just setting up my static blog using Jekyll.

I installed everything from Gemfile by bundle install. My Gemfile looks like this:

source "https://rubygems.org"
gem "github-pages"

group :jekyll-plugins do
    gem "octopress-minify-html"
end

One of the dependencies of the octopress plugin is uglifier 2.7.2, and it was installed correctly in the first bundle install call.

When trying out another plugin that depends on another version of uglifier later, I installed uglifier via

gem install uglifier

Prior to this, the only package I installed with gem is Bundler, and everything else is done via bundle install. The above command installed uglifier 4.1.9, which later caused some problems when building with Jekyll.

But then it seems I can't revert uglifier to 2.7.2. Bundler has been resolving the depencency of octopress plugin to uglifier 4.1.9 (incompatible) ever since. I tried sudo bundle clean --force and sudo gem uninstall --all, delete ~/.bundle and ~/.gem and start all over again, but still Bundler installs uglifier 4.1.9 as the depencency.

I tried the whole procedure on a new VM and start from apt install ruby ruby-dev, this time Bundler resolves the dependency to 2.7.2 correctly and I was able to build my site. It also does the resolution correctly on Travis CI.

Question: How can I make Bundler forget about uglifier 4.1.9 and stop the bad dependency resolution on my machine?

Note: The working directory is kept clean by deleting the whole WD and re-cloning from GitHub, so it's consistent across environments.

Upvotes: 0

Views: 136

Answers (1)

ashmaroli
ashmaroli

Reputation: 5434

Try one of the following:

  1. Run jekyll commands in the context of the Gemfile:

    bundle exec jekyll build
    
  2. Re-align your lockfile and then build:

    i. Run bundle update

    ii. Run bundle exec jekyll build

  3. Re-generate your lockfile and then build:

    i. Delete Gemfile.lock

    ii. Run bundle exec jekyll build

Upvotes: 0

Related Questions