Closed rromanchuk closed 5 years ago
Hi there! Thanks for filing this issue.
I found this thread on caching brew installs — it sounds like it might be helpful. Maybe give that a try and let us know if it works ?
@teesloane after a lot of battling and compromises i got to place where i can build. I had the most difficulties preventing circleci
s opinion on toochain from interfering with my own build environment. I didn't want to compromise how i develop locally just to be able to build. One thing that really hindered this process is chruby being sourced from .bashrc
It would be nice if circleci isn't going to include images with the latest stable of ruby, to instead offer an image with no modifications. Since fastlane (and cocoapods) is ubiquitous with ios, especially when it comes to testing and building, and fastlane requires ruby, it needs first class ruby support, even if that means an image with nothing but system ruby, at least that way i don't have to spend half my build minutes removing circleci modifications
At the very least echo "ruby-2.6.1" > ~/.ruby-version
, or in other words echo "ruby-[LATEST_STABLE_RUBY]" > ~/.ruby-version
needs to always work, without requiring me to compile ruby. Compiling the latest stable version of ruby isn't a big deal, but properly configuring this version and figuring out how to cache between builds, not only that, but ensuring you're using the correct bundler and gems is extremely difficult. chruby
is supposed to be "lightweight", but that's only true if you're working with persistence. It's extremely fragile when working with ephemeral images.
Here's a challenge for circleci devs. Create a circleci config that builds this project successfully https://github.com/CircleCI-Public/circleci-demo-ios
Here are the requirements:
Commit a .ruby-version
file with 2.6.1
Lock your Gemfile to ruby '2.6.1'
, right now you aren't locking a version https://github.com/CircleCI-Public/circleci-demo-ios/blob/master/Gemfile
Your Gemfile.lock
should be committed and include
BUNDLED WITH
2.0.1
Add package management, like cocoapods, and add a package, like Alamofire
Add the following to one of your fastlane lanes
bundle_install
cocoapods
The above requirements are really pretty basic.
Here's my go so far
version: 2.1
executors:
spar-ios-executor:
macos:
xcode: "10.1.0"
working_directory: /Users/distiller/project
environment:
FL_OUTPUT_DIR: output
BUNDLE_CLEAN: true
BUNDLE_BIN: true
BUNDLE_JOBS: 3
BUNDLE_RETRY: 3
BUNDLE_USER_HOME : ~/.bundle
BUNDLE_USER_CACHE : ~/.bundle/cache
BUNDLE_USER_CONFIG : ~/.bundle/config
BUNDLE_USER_PLUGIN : ~/.bundle/plugin
BUNDLE_PATH: ~/.bundle/vendor
shell: /bin/bash --login -eo pipefail
references:
rubies_cache_key: &rubies_cache_key
v2-rubies-{{ .Branch }}-{{ .Revision }}
rubies_cache_key2: &rubies_cache_key2
v2-rubies-{{ .Branch }}-
rubies_cache_key3: &rubies_cache_key3
v2-rubies-
bundler_cache_key: &bundler_cache_key
v10-bundler-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
bundler_cache_key2: &bundler_cache_key2
v10-bundler-{{ arch }}-{{ .Branch }}-
bundler_cache_key3: &bundler_cache_key3
v10-bundler-{{ arch }}-
workspace_root: &workspace_root
~/
attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root
restore_rubies: &restore_rubies
restore_cache:
keys:
- *rubies_cache_key
- *rubies_cache_key2
- *rubies_cache_key3
save_rubies: &save_rubies
save_cache:
key: *rubies_cache_key
paths:
- ~/.rubies
- ~/.ruby-version
- ~/.gems
restore_bundler: &restore_bundler
restore_cache:
keys:
- *bundler_cache_key
- *bundler_cache_key2
- *bundler_cache_key3
save_bundler: &save_bundler
save_cache:
key: *bundler_cache_key
paths:
- ~/.bundle
update_ruby: &update_ruby
run:
name: Updating system ruby
command: |
cd ~/
[ ! -d ~/.rubies/ruby-2.6.1 ] && ruby-install ruby 2.6.1
source ~/.bash_profile
echo "ruby-2.6.1" > ~/.ruby-version
ruby -v
gem update --system --verbose
gem install bundler --verbose
rm -rf ~/.rubies/ruby-2.1.5
rm -rf ~/.rubies/ruby-2.5.3
rm -rf ~/.rubies/ruby-2.4.5
rm -rf ~/.gem/ruby-2.4.5
rm -rf ~/.gem/ruby-2.5.3
update_brew: &update_brew
run:
name: update brew
command: |
brew update
brew_bundle: &brew_bundle
run:
name: Update brew
command: |
brew bundle
bundle_install: &bundle_install
run:
name: Update gems
command: |
gem install bundler --verbose
bundle check || bundle install --verbose
bundle install --binstubs --verbose
debug: &debug
run:
command: |
ls -la ~/
ls -la ~/project
pwd
bundle env
gem env
ruby -v
bundler -v
jobs:
checkout:
executor: spar-ios-executor
steps:
- *debug
- *restore_rubies
- *update_ruby
- *save_rubies
- checkout
- *restore_bundler
- *bundle_install
- *debug
- *save_bundler
- *debug
- run: rm -rf .git
- persist_to_workspace:
root: ~/
paths:
- .gems
- .rubies/ruby-2.6.1/
- .bundle
- project
- .ruby-version
release:
executor: spar-ios-executor
steps:
- *attach_workspace
- run: gem install bundler --verbose
- *debug
- run: bundle exec fastlane release_circleci
beta:
executor: spar-ios-executor
steps:
- *attach_workspace
- run: gem install bundler --verbose
- *debug
- *brew_bundle
- run: bundle exec fastlane beta_circleci
internal-beta:
executor: spar-ios-executor
steps:
- *attach_workspace
- run: gem install bundler --verbose
- *debug
- *brew_bundle
- run: bundle exec fastlane internal_circleci
test:
executor: spar-ios-executor
steps:
- *attach_workspace
- run: gem install bundler --verbose
- *debug
- run: bundle exec fastlane test
workflows:
version: 2
test:
jobs:
- checkout:
filters:
branches:
only: development
- test:
requires:
- checkout
filters:
branches:
only:
- development
- master
tagged-release-build:
jobs:
- checkout:
filters:
tags:
only: /^release-v.*/
branches:
ignore: /.*/
- release:
requires:
- checkout
filters:
tags:
only: /^release-v.*/
branches:
ignore: /.*/
tagged-beta-build:
jobs:
- checkout:
filters:
tags:
only: /^beta-v.*/
branches:
ignore: /.*/
- internal-beta:
requires:
- checkout
filters:
tags:
only: /^beta-v.*/
branches:
ignore: /.*/
Hi @rromanchuk — thank you for the details on the issue. I'll take some time to try and go through our demo app with your provided configuration — it sounds like working through that will help us find what might be lacking with our iOS configuration guide. Any / All issues that can't be resolved in the process I'll pass on to support/development teams as we work to improve the Mac OS executor offering!
Thanks again for the feedback; I'm sorry it's not particularly clear / easy to get things up and running. At the very least, I'm glad we have a list of things and priorities for what we can improve.
Thanks @teesloane! Adding @marcomorain to see if he can help out with this as well
Hi @rromanchuk
Sorry that you are having trouble getting the correct version of Ruby to run your build.
I'm having some difficulty parsing this piece of your comment above:
One thing that really hindered this process is chruby being sourced from .bashrc It would be nice if circleci isn't going to include images with the latest stable of ruby, to instead offer an image with no modifications. Since fastlane (and cocoapods) is ubiquitous with ios, especially when it comes to testing and building, and fastlane requires ruby, it needs first class ruby support, even if that means an image with nothing but system ruby, at least that way i don't have to spend half my build minutes removing circleci modifications
Can you explain a little more what you mean here? Our images come with the system Ruby as the default ruby
out of the box. Since the default shell is not a login shell, then chruby
is not active, and will thus leave the system Ruby in place.
Did you experience something different?
Stepping back, what version of Ruby do you use locally and how do you install it?
Description
Very very very basic setup does not work.
Per documentation https://circleci.com/docs/2.0/testing-ios/#using-custom-ruby-versions
Location
Vanilla setup using the latest stable release of ruby for mac os.
Steps to Reproduce
chruby: unknown Ruby: ruby-2.6.1
More full example, but basically take your documentation, and use the latest stable ruby version.
ruby-install 2.6.1
, works, if you want to spend an hour per build. https://gist.github.com/rromanchuk/f36989e2682cf9c7068f67081d6ace58I'm trying to figure out how to cache brew, or ruby-install, or whatever, and no, i don't want to build a docker image (OR drop down to 2.5.3) in order to run hello world.