Ruby bundle exec silently fails to run gem - ruby

I have Ruby 2.1.5p273 and RubyGems v2.4.6 on CentOS 7.1 x86_64. When I run bundle exec bin/awesome_app I get no error on the screen, and my app doesn't run. However, with --verbose turned on, I see this:
$ bundle --verbose exec bin/recall_app
ERROR: "bundle install" was called with arguments ["exec", "bin/recall_app"]
Usage: "bundle install [OPTIONS]"
However, I've already ran bundle install in the directory of the gem. I'm not sure what else I would need to do.

As per your request: To run a Sinatra app with bundler the command is bundle exec ruby your_main_app_file.rb.
Here are the official Docs

Related

Error upon `bundle exec jekyll 3.8.7 new .` for Github Pages

Goal
Initiate a Github Page using Jekyll. I'm following the Github Pages docs.
Problem
Upon executing:
bundle exec jekyll 3.8.7 new .
The following error is returned:
fatal: 'jekyll 3.8.7' could not be found. You may need to install the jekyll-3.8.7 gem or a related gem to be able to use this subcommand..
Also note that (a) Jekyll 3.8.7 is the current dependency version for Github Pages and (b) the same error is returned if I attempt it for Jekyll 4.1.0.
Context
I tried the recommendation in this SO post -- $ bundle init, $ bundle add jekyll -- but that didn't solve my problem.
System details:
$ which ruby
/Users/vishrutarya/.rbenv/shims/ruby
$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
$ jekyll -v
jekyll 4.1.0
$ which jekyll
/Users/vishrutarya/.gem/ruby/2.7.0/bin/jekyll
For me, adding underscores did the trick.
I installed version 3.8.7 manually. With gem list, you can check if it is
actually installed.
Then i used bundle exec jekyll _3.8.7_ new . --force and it worked.
Ran into the same issue on MacOS. This is what I ended up doing:
Create a new dir, let's call it blog
Run bundle init
In the Gemfile, add the line gem "jekyll", "= 3.8.7"
Run bundle i
You can verify the jekyll version by issuing bundle exec jekyll -v
Create a docs/ directory in the same folder
Run bundle exec jekyll new .
Run bundle i again in docs/ directory
To serve, run bundle exec jekyll serve in the docs/ directory
I hope this helps!

Jenkins, rbenv, bundler - When using Jenkins and rbenv, how does the rbenv plugin preinstall bundler, and why isn't it in my case?

I'm setting up a CI environment on OSX using Jenkins and Appium's Ruby library.
I'm using a rake task to launch my test suite in RSpec.
Using a similar configuration, I was able to run the tests with Jenkins on another machine. I'm now using rbenv (and the rbenv plugin) and having some issues.
Here's what I get when I try to run the job:
$ bash -c "[ -d \$HOME/.rbenv-jenkins ]"
$ bash -c "[ -d \$HOME/.rbenv-jenkins/plugins/ruby-build ]"
$ bash -c "cd /Users/Shared/Jenkins/Home/workspace/Tests && env RBENV_ROOT\=\$HOME/.rbenv-jenkins RBENV_VERSION\=2.2.5 CONFIGURE_OPTS\= RUBY_CONFIGURE_OPTS\= \$HOME/.rbenv-jenkins/bin/rbenv local 2>/dev/null || true"
Use local Ruby version 2.2.5.
$ bash -c "mkdir \$HOME/.rbenv-jenkins/.lock"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv-jenkins RBENV_VERSION\=2.2.5 CONFIGURE_OPTS\= RUBY_CONFIGURE_OPTS\= \$HOME/.rbenv-jenkins/bin/rbenv versions --bare"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv-jenkins RBENV_VERSION\=2.2.5 CONFIGURE_OPTS\= RUBY_CONFIGURE_OPTS\= \$HOME/.rbenv-jenkins/bin/rbenv rehash"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv-jenkins RBENV_VERSION\=2.2.5 CONFIGURE_OPTS\= RUBY_CONFIGURE_OPTS\= \$HOME/.rbenv-jenkins/bin/rbenv exec gem list"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv-jenkins RBENV_VERSION\=2.2.5 CONFIGURE_OPTS\= RUBY_CONFIGURE_OPTS\= \$HOME/.rbenv-jenkins/bin/rbenv rehash"
$ bash -c "rm -rf \$HOME/.rbenv-jenkins/.lock"
[Tests] $ bundle exec rake ios
FATAL: rake execution failed
java.io.IOException: Cannot run program "bundle" (in directory "/Users/Shared/Jenkins/Home/workspace/Tests"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:240)
at hudson.Proc$LocalProc.<init>(Proc.java:212)
etc.
It seems like there is an issue with bundler's exec not being where it is supposed to be.
I've tried adding
export PATH="$HOME/.rbenv-jenkins/bin:$PATH"
to the path in a few ways, but it seems like it doesn't make a difference - when it's a shell step I see it run, but I get no change.
I have preinstall rake and bundler enabled with my rbenv plugin, but I don't see them getting installed - I'm not sure why.
I am able to run tests via rspec, rake and bundle exec rake when I'm logged in to the Jenkins user.
Any idea what's not doing what it's supposed to be? Let me know if there are any missing details, and thank you!
edit:
When I add gem install bundle and gem install rake shell commands, I get the following:
+ gem install bundler
Successfully installed bundler-1.13.2
Parsing documentation for bundler-1.13.2
Done installing documentation for bundler after 4 seconds
1 gem installed
+ gem install rake
ERROR: Error installing rake:
"rake" from rake conflicts with /Users/Shared/Jenkins/.rbenv-jenkins/versions/2.2.5/bin/rake
Build step 'Execute shell' marked build as failure
Finished: FAILURE
My pre-install gems are rake,bundler - but it seems like only rake gets pre-installed correctly.
Running the job without installing rake (and with an rbenv rehash following the bundler install), I get the same error.
In this case, it turned out to be an error with gem dependencies - a bad nokogiri installation when all was said and done.
I was able to reveal the error message that got me hunting by running bundle exec rake ios (my test task) as a shell command rather than as a rake task via the plugin.
From there, I got an error about a bad version and after trying some gemfile tweaks (and nuking my Gemfile.lock), I ran bundle install as a shell line and noticed the nokogiri installation failing in familiar ways (due to some Xcode version juggling that I suspect is fairly idiosyncratic).
So, if you're lost and looking for guidance in a similar spot, try running the task as a shell line so you get more verbose errors.

`bundle exec` doesn't work, says "`mri_22` is not a valid platform"

I'm trying to run a command using bundle exec in my Ruby project. Whenever I run it, though, I get an error message that looks like:
$ bundle exec rake test
`mri_22` is not a valid platform. The available options are: [:ruby, :ruby_18,
:ruby_19, :ruby_20, :ruby_21, :mri, :mri_18, :mri_19, :mri_20, :mri_21, :rbx,
:jruby, :jruby_18, :jruby_19, :mswin, :mingw, :mingw_18, :mingw_19, :mingw_20,
:mingw_21, :x64_mingw, :x64_mingw_20, :x64_mingw_21]
How do I get bundle to work?
The version of bundler that you're running is out of date. Install the newest bundle gem by running
gem update bundler
Source: https://github.com/codeforamerica/congress/issues/10

bundle command not found heroku

I am trying to use ruby 1.8.7 in my heroku application but the application does not launch. Heroku shows following errors in the console:
2012-10-30T13:29:08+00:00 app[web.2]: bash: bundle: command not found
heroku run "bundle --version" also returns in command not found:
heroku run "bundle --version"
Running `bundle --version` attached to terminal... up, run.1
bash: bundle: command not found
Any ideas on what might be issue here ?
The code will look like this with the newest version:
heroku config:add GEM_PATH=vendor/bundle/1.8
Have you installed a new ruby version? Good chance that ruby version doesnt have bundler installed, use
heroku run 'gem install bundler'
after installing a new ruby!
You need to have the supported Ruby buildpack set:
heroku buildpacks:set heroku/ruby

Bundle install runs from incorrect directory

I'm building a simple thor based generator for some internal projects, and can't seem to get bundle install running from the correct directory.
As I run the new [APP_NAME] function, it should create the directories and files, then run bundle install to install the gems required for the application.
The source of the generator function:
def create
puts "Creating application #{name}"
directory 'application', "#{name}"
Dir.chdir("#{Dir.pwd}/#{name}") do
puts `bundle install`
end
end
And the console output from running the command that calls this create method:
$ bundle exec bin/my_gem new test_app
Creating application test_app
create test_app
create test_app/Gemfile
create test_app/Guardfile
create test_app/README.md
create test_app/app/controllers
create test_app/app/helpers
create test_app/app/models
create test_app/app/views
Using thor (0.14.6)
Using my_gem (0.0.1)
Using bundler (1.1.3)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
As you can see, it is running bundle install but it's running it in my current directory (thor, bundler, my_gem), as opposed to the test_app directory (guard, guard-coffeescript, guard-less, and others) .
Running other commands such as ls or pwd give the expected results:
Gemfile
Guardfile
README.md
app
and
/Users/davidlumley/Development/Gems/my_gem/test_app
Not sure if it makes any difference, but I use RVM for managing my rubies.
Sounds like your app is already using bundler and you have a bundler-inside-bundler problem. Try this:
Bundler.with_clean_env do
puts `bundle install`
end
I'm guessing what's happening is that your outer bundler sets the BUNDLE_GEMFILE env variable to your app's Gemfile, and then your inner bundler ends up inheriting it.
Please try this i will sure helps you.
rvm gemset create app_name
rvm use ruby-1.9.2#app_name
Ruby version what else you used.
then install bundler gem
gem install bundler.
Then bundle install and run server..

Resources