I can't explain this -- why does globally installed gem with script fail in a directory with a Gemfile?

I have a gem installed system-wide called `scrapers` that has a binary
called `rubytapas`. It will run nearly everywhere *except* within a
directory that contains a Gemfile.

It can be a completely empty directory otherwise, and the Gemfile can
be empty. It still fails by getting confused about finding
dependencies.

The gist https://gist.github.com/tamouse/9822711 shows what is
happening, I think.

The gist of the gist is:

$ rubytapas
Commands:
  rubytapas all # Download all rubytapas episodes
  rubytapas download # Downloads the listed episode's files
into a new directory with the episode tag in the given directory
  rubytapas help [COMMAND] # Describe available commands or one
specific command

$ touch Gemfile

$ rubytapas
/opt/rubies/ruby-2.0.0-p353/bin/rubytapas:4:in `require': cannot load
such file -- thor (LoadError)
from /opt/rubies/ruby-2.0.0-p353/bin/rubytapas:4:in `<main>'

Gem scrapers: https://github.com/tamouse/scrapers

And I have the answer, just another stupid mouse trick. :slight_smile:

I had:

require 'rubygems'
require 'bundler/setup'

at the top of the bin file, so it was doing exactly what I told it to,
instead of what I wanted to have it do.

···

On Thu, Mar 27, 2014 at 8:03 PM, tamouse pontiki <tamouse.lists@gmail.com> wrote:

I have a gem installed system-wide called `scrapers` that has a binary
called `rubytapas`. It will run nearly everywhere *except* within a
directory that contains a Gemfile.

It can be a completely empty directory otherwise, and the Gemfile can
be empty. It still fails by getting confused about finding
dependencies.

The gist **SOLVED** Why does globally installed gem/script fail when run in a directory with a Gemfile? · GitHub shows what is
happening, I think.

The gist of the gist is:
**SOLVED** Why does globally installed gem/script fail when run in a directory with a Gemfile? · GitHub

$ rubytapas
Commands:
  rubytapas all # Download all rubytapas episodes
  rubytapas download # Downloads the listed episode's files
into a new directory with the episode tag in the given directory
  rubytapas help [COMMAND] # Describe available commands or one
specific command

$ touch Gemfile

$ rubytapas
/opt/rubies/ruby-2.0.0-p353/bin/rubytapas:4:in `require': cannot load
such file -- thor (LoadError)
from /opt/rubies/ruby-2.0.0-p353/bin/rubytapas:4:in `<main>'

Gem scrapers: GitHub - tamouse/scrapers: Web site scrapers using Mechanize and other goodies.

:slight_smile:

Looks like a useful gem.

···

On Thu, Mar 27, 2014 at 8:28 PM, tamouse pontiki <tamouse.lists@gmail.com>wrote:

And I have the answer, just another stupid mouse trick. :slight_smile:

I had:

require 'rubygems'
require 'bundler/setup'

at the top of the bin file, so it was doing exactly what I told it to,
instead of what I wanted to have it do.

Feel free -- fork it, play with it, PRs welcome

···

On Fri, Mar 28, 2014 at 1:26 PM, Eric Christopherson <echristopherson@gmail.com> wrote:

On Thu, Mar 27, 2014 at 8:28 PM, tamouse pontiki <tamouse.lists@gmail.com> > wrote:

And I have the answer, just another stupid mouse trick. :slight_smile:

I had:

require 'rubygems'
require 'bundler/setup'

at the top of the bin file, so it was doing exactly what I told it to,
instead of what I wanted to have it do.

:slight_smile:

Looks like a useful gem.