technicalpickles / jeweler

Opinionated tool for creating and managing Rubygem projects
MIT License
1.48k stars 164 forks source link

Need to require rubygems for ruby 1.8 #220

Closed aia closed 12 years ago

aia commented 12 years ago

Still need to require rubygems for ruby 1.8 compatibility

ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]

bin/jeweler 
./bin/../lib/jeweler/generator.rb:1:in `require': no such file to load -- git (LoadError)
    from ./bin/../lib/jeweler/generator.rb:1
    from bin/jeweler:4:in `require'
    from bin/jeweler:4

technicalpickles commented 12 years ago

I'm not sure this is quite the right path. In general, you don't want to require rubygems in your executables. With bundler based projects, you can bundle exec stuff that is in bin/, so might be worth checking out how that works

aia commented 12 years ago

bundle exec would work. I think a conditional require in the bin/executable is less confusing. Running an executable just as an executable is what people used to. After all, Jewler is trying to use "#!/usr/bin/env ruby" as a shell and not the bundler. Doing a rubygems require in the library does not make sense because the library will be required at some point somewhere before it gets executed.

technicalpickles commented 12 years ago

Side note, but the commit for this actually has a commented out require :)

I don't think I ever saw this with 1.8 because I turned on rubygems by default for my ruby. Recently turned that off though, since rvm doesn't really recommend it.

Anyways, I'm not sure which is preferred, because I suspect there's weird edge cases either way we go (requiring rubygems or not). I do know that using bundler on a project, you can just bundle exec stuff out of the bin directory as if it was a bin in your Gemfile.

technicalpickles commented 12 years ago

Just kidding, found a better way. I looked up how bundler's gemspec works and copied that :)

bundle exec jeweler will be the preferred way of running in development, or through a rubygems wrapper (ie that it installs when you gem install jeweler) otherwise.

aia commented 12 years ago

Sounds good :-)