Error while following GKE tutorial to run rails on GKE - ruby-on-rails

While following https://cloud.google.com/solutions/migrating-ruby-on-rails-apps-on-heroku-to-gke I get the error:
"/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in find_spec_for_exe': Could not find 'bundler' (2.2.15) required by your /usr/src/app/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.2.15`
from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
from /usr/local/bin/bundle:23:in `<main>'"
when I try to run: docker build -t ruby-app .
Anybody know what's wrong?

Adding the line
RUN gem install bundler
in the Dockerfile before the line
RUN bundle install
did the trick.

Related

Rails container build but no start - macbook M1

I have an app that I can build the container, but not able to start
The error message when I try to start it:
Activating bundler (~> 2.3) failed:
Could not find 'bundler' (2.3.18) required by `$BUNDLER_VERSION`.
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.3.18`
Checked in 'GEM_PATH=/root/.gem/ruby/2.5.0:/usr/local/lib/ruby/gems/2.5.0:/usr/local/bundle' , execute `gem env` for more information
To install the version of bundler this project requires, run `gem install bundler -v '~> 2.3'`
The Dockerfile already has:
FROM --platform=linux/amd64 ruby:2.5.9-slim-stretch
(...)
ENV BUNDLER_VERSION 2.3.18
RUN gem update --system 3.2.3
RUN gem install bundler -v "$BUNDLER_VERSION"
I had to manually run the bundler install, even it should run on build
docker run bundle install

docker build error Gem::Ext::BuildError: ERROR: Failed to build gem native extension for mimemagic-0.3.9

I have to build a docker image on my local machine to verify whether it is a building an image or not but I am facing this issue while building the docker image on a local machine.
Installing mime magic 0.3.9 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/bundle/gems/mimemagic-0.3.9/ext/mimemagic
/usr/local/bin/ruby -I/usr/local/lib/ruby/2.7.0/rubygems -rrubygems
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.1/exe/rake
RUBYARCHDIR\=/usr/local/bundle/extensions/x86_64-linux/2.7.0/mimemagic-0.3.9
RUBYLIBDIR\=/usr/local/bundle/extensions/x86_64-linux/2.7.0/mimemagic-0.3.9
rake aborted!
Could not find MIME type database in the following locations:
["/usr/local/share/mime/packages/freedesktop.org.xml",
"/opt/homebrew/share/mime/packages/freedesktop.org.xml",
"/usr/share/mime/packages/freedesktop.org.xml"]
/usr/local/bundle/gems/mimemagic-0.3.9/ext/mimemagic/Rakefile:25:in `block in
<top (required)>'
Tasks: TOP => default
(See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in /usr/local/bundle/gems/mimemagic-0.3.9 for
inspection.
Results logged to
/usr/local/bundle/extensions/x86_64-linux/2.7.0/mimemagic-0.3.9/gem_make.out
An error occurred while installing mimemagic (0.3.9), and Bundler cannot
continue.
Make sure that `gem install mimemagic -v '0.3.9' --source
'https://rubygems.org/'` succeeds before bundling.
Modify the Dockerfile to install the shared-mime-info package. E.g. on Debian-based images:
RUN apt-get update && apt-get install -y shared-mime-info
If it still won't work, then you may need to update the mimemagic gem. On your host, update mimemagic in the Rails app's Gemfile/Gemfile.lock. You may need to install shared-mime-info first: If the host is macOS, you may need to run brew install shared-mime-info; if the host is Ubuntu, you may need to run apt-get install shared-mime-info. Then run
bundle update mimemagic
If your Dockerfile downloads the Rails app from a repo, push your changes to that repo first. Or, for testing, modify the Dockerfile to copy in the Rails app from the host instead.
If you are using macOS, try the following
brew install shared-mime-info
bundle update mimemagic
And the try to bundle your gem file

RubyMine 2019.1 can't run rake tasks

I got a Rails project that uses Ruby 2.5.3 and I can run bin/rake --tasks from the terminal just fine:
$ rbenv version
# 2.5.3 (set by /Users/me/myproject/.ruby-version)
However, I get a message each time RubyMine telling me that rake --tasks can't be executed.
This is more of a nuisance than a real problem but I still want to get this fixed.
Interestingly, a different rubyframework 2.6.0 is used and it is the "native" ruby rather than one of my rbenv installations:
Error:[rake --tasks] /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.0.2) required by your /Users/besi/Dropbox/projects/boexli/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.0.2`
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
from /usr/bin/bundle:23:in `<main>'
Error:[rake --prereqs] /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.0.2) required by your /Users/besi/Dropbox/projects/boexli/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.0.2`
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
from /usr/bin/bundle:23:in `<main>'
I think, if I could change that framework 2.6 to my default 2.5.3 the issue would be resolved, but I can't seem to find that setting.
The SDK from which that task is executed does not show up the SDK Dialog at all.

Could not find 'bundler' (2.1.4) required by your /home/rails/webapp/Gemfile.lock. (Gem::GemNotFoundException) running docker build

I've been running into this problem whenever I try to run docker build -t ruby-app ., I get the following error:
Step 6/8 : RUN bundle install
---> Running in daa149748210
/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /home/rails/webapp/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`
from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
from /usr/local/bin/bundle:23:in `<main>'
The command '/bin/sh -c bundle install' returned a non-zero code: 1
My Dockerfile is the following:
#Dockerfile
FROM ruby:latest
ENV HOME /home/rails/webapp
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
WORKDIR $HOME
ADD Gemfile* $HOME/
RUN bundle install
ADD . $HOME
CMD ["rails", "server", "--binding", "0.0.0.0"]
My bundler versions installed on my machine are the following:
➜ gem list bundler
*** LOCAL GEMS ***
bundler (2.1.4)
bundler-unload (1.0.2)
rubygems-bundler (1.4.5)
And my Gemfile.lock was generated by the following versions of Ruby and Bundler
#Gemfile.lock
RUBY VERSION
ruby 2.7.0p0
BUNDLED WITH
2.1.4
Any help would be very much appreciated!
add
RUN gem install bundler
before you invoke bundler, that should do the trick.
Run sudo gem install bundler:2.1.2 -n /usr/local/bin before you invoke

How to fix the Cocoapods installation setup error?

I am trying to install cocoapods in my mac, but I can't get it installed. It shows the following error:
$ sudo gem update --system*
Latest version currently installed.
Aborting.
$ sudo gem install cocoapods**
Successfully installed cocoapods-0.34.4
Parsing documentation for cocoapods-0.34.4
1 gem installed
$ pod setup
/Library/Ruby/Site/2.0.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'cocoapods' (>= 0) among 200 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/(user name)/.rvm/gems/ruby-1.9.3-p374:/Users/vamshiraghu/.rvm/gems/ruby-1.9.3-p374#global', execute `gem env` for more information
from /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:324:in `to_spec'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:58:in `gem'
from /usr/bin/pod:22:in `<main>'
So does anybody know about this error to sort it out?
I have same problem. I got different kinds of error when try different combination of install and uninstall. like
[!] The `master` repo requires CocoaPods 0.32.1 -
or
.rvm/gems/ruby-2.0.0-p598/gems/claide-0.4.0/lib/claide/command.rb:217:in `rescue in run': undefined method `verbose?' for nil:NilClass (NoMethodError)
or
.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require': cannot load such file -- colored (LoadError)
from /Users/riverhuang/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/riverhuang/.rvm/gems/ruby-2.1.5#global/gems/cocoapods-0.36.2/lib/cocoapods/user_interface.rb:8:in `<module:UserInterface>'
from /Users/riverhuang/.rvm/gems/ruby-2.1.5#global/gems/cocoapods-0.36.2/lib/cocoapods/user_interface.rb:7:in `<module:Pod>'
.
.
.
from /Users/riverhuang/.rvm/gems/ruby-2.1.5/bin/pod:23:in `load'
from /Users/riverhuang/.rvm/gems/ruby-2.1.5/bin/pod:23:in `<main>'
Could not find proper version of cocoapods (0.29.0) in any of the sources
Run `bundle install` to install missing gems.
After clear all gem in my computer I finally fixed it. Here is my steps to clear all gems.
gem uninstall --all
sudo gem uninstall --all
After uninstall all gems I reinstall the cocoapods.
sudo gem install cocoapods
Then restart the Terminal and run:
pod setup
I guess it has conflict in dependency gems (wrong version or not in right path). Like once I run "bundle install" it always install cocoapods 0.29.0 and all its dependency. With and without "sodu" install gems and its dependency to different places with version 0.36.2 when I did it.

Resources