Giter VIP home page Giter VIP logo

Comments (9)

dmolesUC avatar dmolesUC commented on August 24, 2024

+1! For example, this task should install bundler, but it fails.

namespace :install do
  desc 'Install/update bundler'
  task :bundler do
    on roles(:all) do |host|
      if test('which bundle')
        info "Bundler is already installed on #{host}"
        execute :gem, 'update', "'^bundler$'"
      else
        execute :gem, 'install', 'bundler'
      end
    end
  end
end

Instead of running gem install bundler, it runs bundle exec gem install bundler, resulting in:

DEBUG [727a18b6] Command: bundle exec gem install bundler
DEBUG [727a18b6]        bash: bundle: command not found

from bundler.

dmolesUC avatar dmolesUC commented on August 24, 2024

As a workaround, I used sh -c:

execute "sh -c 'gem update \"^bundler$\"'"

and

 execute 'sh -c "gem install bundler"'

from bundler.

mattbrictson avatar mattbrictson commented on August 24, 2024

Hi, you could also bypass the prefixing behavior by using a single string argument to execute, like this:

# This bypasses SSHKit's command-prefix behavior
execute "gem install bundler"

Or, if you never want gem to be prefixed, you can exclude it when setting bundle_bins:

# This the default
# set :bundle_bins, %w(gem rake rails)
set :bundle_bins, %w(rake rails)

from bundler.

hugoarpin avatar hugoarpin commented on August 24, 2024

Ran into the same problem!

What is the logic for prefixing gem by bundle exec, when would that apply?
As far as I know there is only one possible rubygems installation per ruby, it isn't decide by bundler or the Gemfile.

Any explanation would be awesome, thanks!

from bundler.

mattbrictson avatar mattbrictson commented on August 24, 2024

I'm also fuzzy on why someone would ever use bundle exec gem, but it does have an effect. If you run gem list you get all gems in your Ruby, vs bundle exec gem list will show only show gem versions that match your Gemfile.lock.

from bundler.

hugoarpin avatar hugoarpin commented on August 24, 2024

Ok thanks you're right, it does seem to have an effect.
But is it wise to have it set as the default behavior?

I personally always want to call the "real" gem, especially during setup, so I fixed it with:

set :bundle_bins, %w(rake rails)

# If wished, calling bundle exec gem could be easily done
execute(:bundle, :exec, :gem, ...)

But this could be a frustrating issue for new users who just want to call "gem".
This is maybe just my opinion, great work by the way!

from bundler.

mattbrictson avatar mattbrictson commented on August 24, 2024

I agree, I don't need bundle exec gem either, but changing that now could break deploys of users that expect that default behavior. There is an easy workaround, so perhaps better documentation is the solution?

from bundler.

hugoarpin avatar hugoarpin commented on August 24, 2024

I understand, maybe a hint to this behavior could be put on the readme of capistrano-rails, since many users will read capistrano-rails but not necessarily capistrano-bundler, but once you know the documentation here is pretty good.

Like I said I'm good now, since I know the behavior, but could be frustrating for new users. At first I thought it was rvm1-capistrano3 who was responsible, but finally troubleshooted it here.

Anyway, thanks for your time dude!

from bundler.

will-in-wi avatar will-in-wi commented on August 24, 2024

It seems like this is more of a documentation issue if anything. If anyone wants to submit a PR for that, go for it!

However, given the age of this ticket, I'm closing. If anyone wants it to stay open, feel free to reopen.

from bundler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.