Shopify / shipit-engine

Deployment coordination
https://shopify.engineering/introducing-shipit
MIT License
1.42k stars 145 forks source link

Disparate Ruby Versions #1371

Closed Phillita closed 1 month ago

Phillita commented 1 month ago

Hello ShipIt Team!

First off, thank you for your commitment to OSS.

I've run into an issue during the setup of the ShipIt project. I've initiated the repo with Ruby 3.1 and went through the setup steps. All was going well until I tried to deploy a test application. This application runs on Ruby 3.4. I get the following error at the bundle step:

Image

I've tried running a setup using the shipit.yml where I set the Ruby version in the dependencies.pre and overrode using the dependencies.override and have had no luck getting past this issue. Below is me trying to run the install by installing/setting the version before the bundle install:

Image

Unfortunately, many projects won't have the same version as the ShipIt project. Can ShipIt detect/install/use the Ruby version from the project it is trying to deploy? I'm likely doing something wrong.

casperisfine commented 1 month ago

Can ShipIt detect/install/use the Ruby version from the project it is trying to deploy?

No it's not, it's part of its simple design, the assumption is that you don't need the full projects to bundle on Shipit, only their deploy scripts.

If I had to do it all over again today, I'd probably do something docker based, but it wasn't that mature back in the day.

An easy way out is often to have the deploy script and dependencies split in a subdirectory and to use machine.directory to work there.

That said your issue is probably in big part because you are bypassing the default generated bundler command, which strips the Ruby constraint: https://github.com/Shopify/shipit-engine/blob/51bc4c86f12437959dfe5a1f02e3cb37435efbe6/app/models/shipit/deploy_spec/bundler_discovery.rb#L33C11-L41

Phillita commented 1 month ago

Thank you for your reply @casperisfine!

You've pointed me in the right direction for where to look. I hadn't realized there was a step to remove this constraint.

That said your issue is probably in big part because you are bypassing the default generated bundler command, which strips the Ruby constraint: https://github.com/Shopify/shipit-engine/blob/51bc4c86f12437959dfe5a1f02e3cb37435efbe6/app/models/shipit/deploy_spec/bundler_discovery.rb#L33C11-L41

You're right. In my last runs, when I used the dependencies.override, I skipped this step. With my earlier runs, I used the default setup without a shipit.yml. For some reason, it isn't removing the Ruby line in the gemfile.

I've now tried running the sed command /usr/bin/sed -i '' '/^ruby\s/d' Gemfile which should remove the ruby version from the file in place but doesn't seem to do that.

Phillita commented 1 month ago

@casperisfine I was playing with the sed command and for some reason I would need to remove the \s from the regex expression for my Unix system to remove the ruby constraint from the gemfile.

Has anyone else run into this? I tested the linux sed command and it works fine.

Working Unix Command: /usr/bin/sed -i '' '/^ruby/d' Gemfile

casperisfine commented 1 month ago

my Unix system

What system is that?

Phillita commented 1 month ago

I'm on a Mac OS Sonoma 14.7

casperisfine commented 1 month ago

I just tried it and it's indeed broken, I suppose sed changed on OSX a while ago.

I think we should change it for /usr/bin/sed -i '' '/^ruby /d' Gemfile

Phillita commented 1 month ago

Tested on my end and that works as expected!