pivotal-sprout / sprout-wrap

Pivotal Labs uses this project with sprout, soloist and librarian-chef to build developer workstations
The Unlicense
157 stars 250 forks source link

sprout can't find bundler (on macOS Sierra) #97

Closed bixu closed 2 months ago

bixu commented 8 years ago

example output:

bixu ☛  caffeinate ./sprout
Successfully installed bundler-1.12.5
1 gem installed
Rubygems 2.0.14.1 is not threadsafe, so your gems will be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
Using awesome_print 1.6.1
Using builder 3.2.2
Using bundler 1.12.5
Using mixlib-config 2.2.1
Using mixlib-shellout 2.2.6
Using libyajl2 1.2.0
Using hashie 2.1.2
Using mixlib-log 1.6.0
Using rack 1.6.4
Using uuidtools 2.1.5
Using diff-lcs 1.2.5
Using erubis 2.7.0
Using highline 1.7.8
Using rspec-support 3.4.1
Using mixlib-cli 1.6.0
Using net-ssh 3.1.1
Using ffi 1.9.10
Using ipaddress 0.8.3
Using plist 3.1.0
Using systemu 2.6.5
Using wmi-lite 1.0.0
Using proxifier 1.0.3
Using multi_json 1.12.1
Using net-telnet 0.1.1
Using sfl 2.2
Using syslog-logger 1.6.8
Using thor 0.19.1
Using minitar 0.5.4
Using chef-config 12.8.1
Using ffi-yajl 2.2.3
Using rspec-core 3.4.4
Using rspec-expectations 3.4.0
Using rspec-mocks 3.4.1
Using net-ssh-gateway 1.2.0
Using net-scp 1.2.1
Using librarian 0.1.2
Using chef-zero 4.5.0
Using ohai 8.16.0
Using rspec_junit_formatter 0.2.3
Using rspec-its 1.2.0
Using mixlib-authentication 1.4.0
Using rspec 3.4.0
Using net-ssh-multi 1.2.1
Using specinfra 2.57.5
Using serverspec 2.36.0
Using chef 12.8.1
Using librarian-chef 0.0.4
Using soloist 1.0.3
Bundle complete! 3 Gemfile dependencies, 48 gems now installed.
Bundled gems are installed into ./vendor/bundle.
Installing chef_handler (1.4.0)
Installing windows (1.42.0)
Installing seven_zip (2.0.1)
Installing build-essential (3.2.0)
Installing dmg (2.4.0)
Installing homebrew (2.1.0)
Installing mingw (0.1.1)
Installing osx (0.1.0)
Installing sprout-base (0.5.0)
Installing sprout-git (0.2.1)
Installing sprout-homebrew (0.3.0)
Installing sprout-jetbrains-editors (0.1.0)
Installing sprout-mysql (0.1.0)
Installing sprout-osx-settings (0.1.0)
Installing sprout-osx-apps (0.2.0)
Installing sprout-postgresql (0.1.0)
Installing sprout-rbenv (0.1.0)
Installing sprout-ruby (0.1.0)
Installing sprout-ssh (0.1.0)
Installing sprout-terminal (0.1.0)
Password:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (>= 1.10) among 55 total gem(s) (Gem::LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:1209:in `block in activate_dependencies'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:1198:in `each'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:1198:in `activate_dependencies'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:1180:in `activate'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:48:in `gem'
    from /Users/irvin/smartb/sprout-wrap/vendor/bundle/ruby/2.0.0/bin/chef-solo:22:in `<main>'
aramprice commented 8 years ago

I'm not sure about your particular setup but I am using the files below successfully on the latest macOS beta. I have not done extensive ground-up testing since the first beta however, I've just been re-sprouting the same machine post-updates.

The contents of sprout are somewhat different and do expose a larger surface area than the sprout script in this repo - I'm not yet sure this is a good thing. Pinging @wendorf as he may have other insights / ideas.


#!/usr/bin/env bash

set -e

function use_local_gems() {
  SPROUT_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  export SPROUT_HOME
  export GEM_HOME="${SPROUT_HOME}/tmp/ruby/2.0.0"
  export GEM_PATH="${GEM_HOME}"
  export PATH="${GEM_HOME}/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"

  current_ruby=$(which ruby)
  if [ "${current_ruby}" != '/usr/bin/ruby' ]; then
    echo -e "\033[31mWarning: sprout should be run with system ruby; using '${current_ruby}'\033[0m"
  fi
  echo "# - Using $(${current_ruby} -v)"
}

function ensure_in_sprout_home() {
  if [ "${SPROUT_HOME}" != "$(pwd)" ]; then
    echo "Error: sprout must be run from ${SPROUT_HOME}"
    exit 1
  fi
}

function bundle_exec() {
  if bundler_installed; then
    echo "# - Using $(bundle -v)"
  else
    gem install bundler --no-document
  fi

  if bundle check > /dev/null 2>&1; then
    echo '# - Gemfile dependencies satisfied'
  else
    bundle install --jobs 6
  fi

  bundle exec "${@}"
}

function bundler_installed() {
  command -v bundle > /dev/null
}

function update_resources() {
  gem install bundler --no-document
  bundle update
  bundle exec librarian-chef update
}

function main() {
  use_local_gems
  ensure_in_sprout_home

  case "${1}" in
    '')
      export LOG_LEVEL="warn" # make chef less noisy
      bundle_exec soloist
      ;;
    exec)
      shift
      bundle_exec "${@}"
      ;;
    update)
      update_resources
      ;;
    *)
      echo "Usage:"
      echo "  sprout               - install dependencies and run 'soloist'"
      echo "  sprout exec some cmd - run 'some cmd' in this cookbooks's bundler context"
      echo "  sprout update:       - update gems and cookbook dependencies"
  esac
}

main "${@}"
source 'https://rubygems.org'

gem 'soloist', require: false

group :development do
  gem 'foodcritic', '< 7.0.0', require: false # foodcritic >=7.0.0 drops support for ruby v2.0.0
  gem 'rake', require: false
  gem 'rspec', require: false
  gem 'rubocop', require: false
  gem 'chefspec', require: false
end

# Temporarily lock these gems. Newer versions depend on Ruby >= 2.1.0
# Remove this once https://github.com/mkocher/soloist/issues/39 is closed
gem 'chef', '~> 12.8.1', require: false
gem 'chef-zero', '~> 4.5.0', require: false
gem 'fauxhai', '< 3.7.0', require: false # >=3.7.0 requires ruby v2.1
gem 'ffi-yajl', '< 2.3.0', require: false # >=2.3.0 requires ruby v2.1
gem 'ohai', '< 8.18.0', require: false # >=8.18.0 requires ruby v2.2.2
gem 'rack', '< 2.0.0', require: false # >=2.0.0 requires ruby v2.2.2
site 'https://supermarket.getchef.com/api/v1'

cookbook 'sprout-our-team', path: '.'

cookbook 'osx', github: 'pivotal-sprout/osx'

cookbook 'sprout-base', github: 'pivotal-sprout/sprout-base'
cookbook 'sprout-chruby', github: 'pivotal-sprout/sprout-chruby'
cookbook 'sprout-git', github: 'pivotal-sprout/sprout-git'
cookbook 'sprout-osx-settings', github: 'pivotal-sprout/sprout-osx-settings'

# mingw 1.0 and build-essential 4.0 add a dependency to compat_resource,
# which does not work with Rubygems 2.0.14, which ships with OS X 10.11.4
cookbook 'mingw', '= 0.1.1'
cookbook 'build-essential', '= 3.2.0'
aramprice commented 2 months ago

Going to archive this repo, closing.