'Could not find nokogiri-1.11.4-x86_64-linux in any of the sources - Macbook M1 running Docker
I'm running a Rails app and getting this error whilst running in Docker.
There are no results on Google for what the cause might be.
The gem doesn't appear in my Gemfile so it must be a dependency of Rails or another gem.
The previous error I was getting was:-
Could not find 'nokogiri' (>= 1.5.9) among 144 total gem(s) (Gem::MissingSpecError)
To resolve this, I added gem install nokogiri to my Dockerfile, which now gives me the title error. Any ideas?
Solution 1:[1]
When you add gem install nokogiri in your Dockerfile, it will install linux compatible nokogiri (1.13.3-x86_64-linux) and will add that to your Gemfile.lock.
When you run rails on your mac, it will need mac compatible nokogiri (1.13.3-x86_64-darwin)
Here is how I fixed this:
- I first ran bundle install from my Mac, that added
1.13.3-x86_64-darwinin my Gemfile.lock. - Before running docker-compose up, I added linux platform to my Gemfile.lock by running:
bundle lock --add-platform x86_64-linux
This is what my Gemfile.lock has now:
...
nokogiri (1.13.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.3-x86_64-linux)
racc (~> 1.4)
...
PLATFORMS
x86_64-darwin-21
x86_64-linux
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Shaunak Sontakke |
