Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Use bundled Gems defined within a Gemfile #157

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

orta
Copy link
Member

@orta orta commented Dec 29, 2015

I've got most of the way.

  • Find out how to use host env's bundler ( or install bundler? )
  • Get the gems actually installing, e.g. deal with circular references

@orta
Copy link
Member Author

orta commented Dec 29, 2015

Currently stuck figuring out how to deal with the circular references for CP and plugins depending on it.

[12:21:51] [Gems] destroot/bundle/bin/bundle-env gem install workbench/ruby/2.1.0/bundler/gems/CocoaPods-3cf3dbcde978/cocoapods-0.39.0.gem workbench/ruby/2.1.0/bundler/gems/CocoaPods-db93068587f0/cocoapods-0.39.0.gem workbench/ruby/2.1.0/bundler/gems/cocoapods-deintegrate-160752789024/cocoapods-deintegrate-0.2.1.gem workbench/ruby/2.1.0/bundler/gems/Core-9fd6c128f989/cocoapods-core-0.39.0.gem workbench/ruby/2.1.0/bundler/gems/Core-e5b64946f634/cocoapods-core-0.39.0.gem workbench/ruby/2.1.0/bundler/gems/Xcodeproj-ffeadb7ca0ed/xcodeproj-0.28.2.gem workbench/ruby/2.1.0/cache/activesupport-4.2.5.gem workbench/ruby/2.1.0/cache/claide-0.9.1.gem workbench/ruby/2.1.0/cache/cocoapods-downloader-0.9.3.gem workbench/ruby/2.1.0/cache/cocoapods-keys-1.6.0.gem workbench/ruby/2.1.0/cache/cocoapods-plugins-0.4.2.gem workbench/ruby/2.1.0/cache/cocoapods-search-0.1.0.gem workbench/ruby/2.1.0/cache/cocoapods-stats-0.6.2.gem workbench/ruby/2.1.0/cache/cocoapods-trunk-0.6.4.gem workbench/ruby/2.1.0/cache/cocoapods-try-0.5.1.gem workbench/ruby/2.1.0/cache/colored-1.2.gem workbench/ruby/2.1.0/cache/dotenv-2.0.2.gem workbench/ruby/2.1.0/cache/escape-0.0.4.gem workbench/ruby/2.1.0/cache/fuzzy_match-2.0.4.gem workbench/ruby/2.1.0/cache/i18n-0.7.0.gem workbench/ruby/2.1.0/cache/json-1.8.3.gem workbench/ruby/2.1.0/cache/minitest-5.8.3.gem workbench/ruby/2.1.0/cache/molinillo-0.4.0.gem workbench/ruby/2.1.0/cache/nap-1.0.0.gem workbench/ruby/2.1.0/cache/netrc-0.7.8.gem workbench/ruby/2.1.0/cache/osx_keychain-1.0.1.gem workbench/ruby/2.1.0/cache/RubyInline-3.12.4.gem workbench/ruby/2.1.0/cache/thread_safe-0.3.5.gem workbench/ruby/2.1.0/cache/tzinfo-1.2.2.gem workbench/ruby/2.1.0/cache/ZenTest-4.11.0.gem --no-document --env-shebang
ERROR:  While executing gem ... (Gem::Resolver::Molinillo::CircularDependencyError)
    There is a circular dependency between cocoapods-deintegrate and cocoapods

@segiddins
Copy link
Member

Issue may just be rubygems not being smart about installing them all at once :( May need to install them in topological order?

install_gem 'cocoapods', install_cocoapods_version
execute "bundling", ["rm", "-rf", WORKBENCH_DIR + "/ruby"]
# Can figure this one out later
bundler = "/Users/orta/.rvm/gems/ruby-2.1.3/wrappers/bundle"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really couldn't figure out how to use the user's install of bundler, tried a bunch of things

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps via $GEM_HOME?

$ echo $GEM_HOME
/Users/kyle/gems
$ ls $GEM_HOME
bin            bundler        doc            specifications
build_info     cache          gems

Remember to fall back to correct path when GEM_HOME isn't set. There is probably some RubyGems/Bundler code to look up this place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the goal of this PR correctly, then you might want to do something like the following to get the path:

$ bundle show gem

@orta
Copy link
Member Author

orta commented Apr 3, 2016

@segiddins - is there an easy way to get the topological order of the gems? ( e.g. could I ask bundler "make the "cocoapods" gem dep tree" then go from the leafs of the dep tree and do a depth first approach? )

@segiddins
Copy link
Member

@orta yes. Bundler.definition.specs.to_a should do it if I'm remembering correctly. Rainforest also has a task for that.

@orta
Copy link
Member Author

orta commented Apr 9, 2016

Interesting, I think I have a newer version of bundler, and now I don't have the issues around topological installs

@orta
Copy link
Member Author

orta commented Apr 10, 2016

@segiddins - I'm a tough point, where I'm not 100% sure if I've hit a bundler bug

$ rake app:prerequisites

[09:01:48] [Submodules] /usr/bin/git submodule update --init --recursive
[09:01:49] [ruby-2.2.3] cd workbench/ruby-2.2.3 && /usr/bin/make install
[... a totally blank ruby is installed]

# installed bundler inside the new hosted ruby env
[09:01:59] [bundling] destroot/bundle/bin/bundle-env gem install bundler --verbose

# Use the new bundler to install our gems
[09:02:03] [bundling] destroot/bundle/bin/bundle install --gemfile bundled-Gemfile

# I get a bunch of these errors:

Ignoring json-1.8.3 because its extensions are not built.  Try: gem pristine json --version 1.8.3
Ignoring json-1.8.2 because its extensions are not built.  Try: gem pristine json --version 1.8.2
Ignoring json-1.7.7 because its extensions are not built.  Try: gem pristine json --version 1.7.7
Ignoring kgio-2.9.2 because its extensions are not built.  Try: gem pristine kgio --version 2.9.2

# Then is starts downloading

Fetching https://github.com/CocoaPods/CocoaPods.git
Fetching https://github.com/CocoaPods/Core.git
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Installing i18n 0.7.0
Installing json 1.8.3 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

# Showing this error:

    current directory: /Users/orta/dev/mac/apps/CocoaPods-app/path/ruby/2.2.0/gems/json-1.8.3/ext/json/ext/generator
/Users/orta/dev/mac/apps/CocoaPods-app/destroot/bundle/bin/ruby -r ./siteconf20160410-46161-ao5uqb.rb extconf.rb
/Users/orta/.rvm/gems/ruby-2.1.3/gems/bundler-1.11.2/lib/bundler/source/git/git_proxy.rb:183:in `allowed_in_path': The git source https://github.com/CocoaPods/CocoaPods.git is not yet checked out. Please run `bundle install` before trying to start your application (Bundler::GitError)
    from /Users/orta/.rvm/gems/ruby-2.1.3/gems/bundler-1.11.2/lib/bundler/source/git/git_proxy.rb:47:in `revision'
    from /Users/orta/.rvm/gems/ruby-2.1.3/gems/bundler-1.11.2/lib/bundler/source/git.rb:215:in `revision'
    from /Users/orta/.rvm/gems/ruby-2.1.3/gems/bundler-1.11.2/lib/bundler/source/git.rb:87:in `install_path'
    from /Users/orta/.rvm/gems/ruby-2.1.3/gems/bundler-1.11.2/lib/bundler/source/path.rb:110:in `expanded_path'

The error message is weird though, it's the JSON gem failing, but then the message talks about how CocoaPods cannot be checked out, even though it was a few lines above, can you think if I'm doing anything odd?

@orta
Copy link
Member Author

orta commented Apr 10, 2016

( sorry sent the message early, wrapped it up in an edit )

I wonder if it's using one bundler environment, then jumping to another, might try a different idea

@segiddins
Copy link
Member

@orta that won't really happen, bundler basically just uses a single definition. If it's telling you something isn't checked out, you might need to add a resolve_remotely! to the definition to make it update the cached git repo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants