This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

add minimal support for bundler/Gemfile in setup

  • Loading branch information...
mpapis committed Mar 15, 2012
1 parent 9c23f10 commit 9114457d487353a0c16e521284ad164835c64b4e
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/shoes/setup.rb
View
@@ -103,6 +103,19 @@ def gem name, version = nil
@steps << [:gem, arg]
end
# TODO: add GUI
def bundler options = {}
bundler_version = options[:version] || Gem::Requirement.default
bundler_file = options[:file] || "Gemfile"
Gem::Specification.find_by_name( "bundler", bundler_version ).activate
rescue Gem::LoadError
Gem::DependencyInstaller.new.install("bundler", bundler_version)
ensure
require 'bundler'
require 'bundler/cli'
Bundler::CLI.new(:gemfile => bundler_file).install
end
def source uri
@steps << [:source, uri]
end

17 comments on commit 9114457

@indirect

This comment has been minimized.

Show comment
Hide comment
@indirect

indirect Mar 18, 2012

Just for the record, this is a bad idea, for several reasons.

  1. Bundler::CLI is not a public API, and therefore could break at any time.
  2. Bundler is built around the idea that it will be run before the application is started.
  3. Bundler must load before anything else does to guarantee that it will work. bundle exec exists in order to load Bundler as quickly as possible. Since you aren't doing that here, things could easily go badly wrong.

If you just want runtime dependencies, you can just use Rubygems as is. Please don't invoke bundler from inside your app, and please don't expect things to work if you install gems and then try to load them from inside the same process. Thanks!

indirect replied Mar 18, 2012

Just for the record, this is a bad idea, for several reasons.

  1. Bundler::CLI is not a public API, and therefore could break at any time.
  2. Bundler is built around the idea that it will be run before the application is started.
  3. Bundler must load before anything else does to guarantee that it will work. bundle exec exists in order to load Bundler as quickly as possible. Since you aren't doing that here, things could easily go badly wrong.

If you just want runtime dependencies, you can just use Rubygems as is. Please don't invoke bundler from inside your app, and please don't expect things to work if you install gems and then try to load them from inside the same process. Thanks!

@indirect

This comment has been minimized.

Show comment
Hide comment
@indirect

indirect Mar 18, 2012

On a somewhat related note, if you want to be able to package up a shoes app and all the gems that it depends on, please look into the bundle install --standalone feature that was added to Bundler in version 1.1. It will allow you to install all the gems from a Gemfile once, by running bundle install, and then start a ruby process that can load those gems without loading rubygems itself.

indirect replied Mar 18, 2012

On a somewhat related note, if you want to be able to package up a shoes app and all the gems that it depends on, please look into the bundle install --standalone feature that was added to Bundler in version 1.1. It will allow you to install all the gems from a Gemfile once, by running bundle install, and then start a ruby process that can load those gems without loading rubygems itself.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 18, 2012

Contributor

+1

Contributor

ccoupe replied Mar 18, 2012

+1

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Mar 18, 2012

Member

@indirect thank you for this advice, I guess I'll be reverting this. I didn't know that CLI was a private API.

--standalone was one of the reasons were were looking toward using bundler to manage an app's gems. I got really excited when I saw this. So we'll figure it out.

Member

steveklabnik replied Mar 18, 2012

@indirect thank you for this advice, I guess I'll be reverting this. I didn't know that CLI was a private API.

--standalone was one of the reasons were were looking toward using bundler to manage an app's gems. I got really excited when I saw this. So we'll figure it out.

@indirect

This comment has been minimized.

Show comment
Hide comment
@indirect

indirect Mar 18, 2012

We would like to provide a public API to invoke CLI commands, we just don't have one solidified yet. That said, all the other problems of running Bundler inside the same process that then loads the gems that Bundler just installed are still present for this particular patch. So there's probably a better way, yeah. :)

indirect replied Mar 18, 2012

We would like to provide a public API to invoke CLI commands, we just don't have one solidified yet. That said, all the other problems of running Bundler inside the same process that then loads the gems that Bundler just installed are still present for this particular patch. So there's probably a better way, yeah. :)

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Mar 18, 2012

Member

We're currently untangling a MASSIVE amount of random code that manages several different kinds of things, so... yeah. I'll ping you about these kinds of issues in the future.

Member

steveklabnik replied Mar 18, 2012

We're currently untangling a MASSIVE amount of random code that manages several different kinds of things, so... yeah. I'll ping you about these kinds of issues in the future.

@mpapis

This comment has been minimized.

Show comment
Hide comment
@mpapis

mpapis Mar 18, 2012

Member

@steveklabnik as there is no other way to get bundler running with shoes I would like to give it a try, I'm testing it on my projects(and it works), maybe we could just not advertise outside of the project ?

Member

mpapis replied Mar 18, 2012

@steveklabnik as there is no other way to get bundler running with shoes I would like to give it a try, I'm testing it on my projects(and it works), maybe we could just not advertise outside of the project ?

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Mar 18, 2012

Member

Sure, let's just keep it private for now.

That means you need to write a new blog post. ;)

Member

steveklabnik replied Mar 18, 2012

Sure, let's just keep it private for now.

That means you need to write a new blog post. ;)

@mpapis

This comment has been minimized.

Show comment
Hide comment
@mpapis

mpapis Mar 18, 2012

Member

I will :D

Member

mpapis replied Mar 18, 2012

I will :D

@wasnotrice

This comment has been minimized.

Show comment
Hide comment
@wasnotrice

wasnotrice Mar 20, 2012

Member

The other option I can see is to use the --standalone option @indirect mentioned, and modify Shoes so that it includes bundled gems when it creates executables and .shy files. That way, we wouldn't need to install gems at runtime.

Member

wasnotrice replied Mar 20, 2012

The other option I can see is to use the --standalone option @indirect mentioned, and modify Shoes so that it includes bundled gems when it creates executables and .shy files. That way, we wouldn't need to install gems at runtime.

@mpapis

This comment has been minimized.

Show comment
Hide comment
@mpapis

mpapis Mar 20, 2012

Member

@wasnotrice then I would need some examples on how to run bundler with shoes

Member

mpapis replied Mar 20, 2012

@wasnotrice then I would need some examples on how to run bundler with shoes

@wasnotrice

This comment has been minimized.

Show comment
Hide comment
@wasnotrice

wasnotrice Mar 20, 2012

Member

@mpapis I don't have an example because we haven't used bundler yet ;) I'm thinking that we could run bundle install --standalone as part of the build process and then copy those files into our packages along with project code.

Member

wasnotrice replied Mar 20, 2012

@mpapis I don't have an example because we haven't used bundler yet ;) I'm thinking that we could run bundle install --standalone as part of the build process and then copy those files into our packages along with project code.

@mpapis

This comment has been minimized.

Show comment
Hide comment
@mpapis

mpapis Mar 20, 2012

Member

but running bundle would require ruby and we do not have it (at least I did not found it)

Member

mpapis replied Mar 20, 2012

but running bundle would require ruby and we do not have it (at least I did not found it)

@wasnotrice

This comment has been minimized.

Show comment
Hide comment
@wasnotrice

wasnotrice Mar 20, 2012

Member

for running during the build process, bundler could just run from a rake task.

for building a .shy, from within Shoes, you may be right. Really, though, it seems to me that gems ought to be bundled at packaging time, not installed at runtime. Maybe we need to extend the .shy metadata to include dependencies.

Member

wasnotrice replied Mar 20, 2012

for running during the build process, bundler could just run from a rake task.

for building a .shy, from within Shoes, you may be right. Really, though, it seems to me that gems ought to be bundled at packaging time, not installed at runtime. Maybe we need to extend the .shy metadata to include dependencies.

@mpapis

This comment has been minimized.

Show comment
Hide comment
@mpapis

mpapis Mar 20, 2012

Member

extending the metadata would mean duplication of bundler code ? also as a note - with rubygems 2.0 there will be already Gemfile like file support builtin, so we can try to sync it with shoes 4.0 release and use it (to simplify everything) - and for now leave it as it is which did not failed for me ...

Member

mpapis replied Mar 20, 2012

extending the metadata would mean duplication of bundler code ? also as a note - with rubygems 2.0 there will be already Gemfile like file support builtin, so we can try to sync it with shoes 4.0 release and use it (to simplify everything) - and for now leave it as it is which did not failed for me ...

@mpapis

This comment has been minimized.

Show comment
Hide comment
@mpapis

mpapis Mar 20, 2012

Member

the main issue here is that we would have to separate setup from run, the process should be reviewed, i'm not sure if the efforts make much sense if we are running away from shoes as a binary towards the gem version.

With the gem version the whole process changes and we get access to standard way of using bundler, which will be a lot simpler compared to current process.

Member

mpapis replied Mar 20, 2012

the main issue here is that we would have to separate setup from run, the process should be reviewed, i'm not sure if the efforts make much sense if we are running away from shoes as a binary towards the gem version.

With the gem version the whole process changes and we get access to standard way of using bundler, which will be a lot simpler compared to current process.

Please sign in to comment.