sqitchers / docker-sqitch

Docker Image packaging for Sqitch
MIT License
35 stars 39 forks source link

Sqitch does not work after homebrew upgrade (Mac OS X) #38

Closed tiguchi closed 1 year ago

tiguchi commented 3 years ago

Problem

When Perl is updated via brew upgrade, sqitch usually stops working with an error message as follows:

/usr/local/bin/sqitch: /usr/local/Cellar/perl/5.32.1/bin/perl: bad interpreter: No such file or directory

Reproduction Steps

For Mac OS X

  1. Install sqitch via brew install sqitch
  2. Upgrade Perl via brew upgrade
  3. Run sqitch

Workaround

The only fix to my knowledge is reinstalling sqitch via brew reinstall sqitch.

Troubleshooting

I guess this is caused by sqitch referencing the previous Perl binary before the upgrade.

Homebrew unfortunately installs minor and patch version updates in new directories, causing problems like this also for other applications.

I'm not sure if this is entirely a homebrew defect or whether there is something that could be done right in the sqitch launcher script or the Homebrew installation script. Maybe there is an upgrade hook for Homebrew packages that could be used for relinking with the correct Perl installation.

Maybe there is also a better way for finding the correct Perl binary such as:

#!/usr/bin/env perl
theory commented 3 years ago

If we switched it to use #!/usr/bin/env/perl, I wonder if it would then fail spectacularly on a major version upgrade that breaks binary compatibility. Would be better if there was a major-version-specific symlink to rely on or something.

tiguchi commented 3 years ago

I just found the following Homebrew ticket, and it looks like pre- and post-install hooks are not a wanted feature: https://github.com/Homebrew/brew/issues/2202

It seems Homebrew does symlink the latest installed versions of all packages in the following base directory:

/usr/local/var/homebrew/linked/

My local installation contains a perl directory with its bin, lib and share sub-directories. No version number in that file path. This doesn't guard against the binary compatibility problem you mention. What would be the worst that could happen in that case? Would sqitch just crash or produce an error message?

theory commented 3 years ago

Yes, probably. But it would happen to folks once a year at most (at major version releases).

bhawnatyagi commented 1 year ago

I am facing the same issue after homebrew upgrade (Mac OS X). I can see this issue is in open status but is there any way to fix this issue? This is a blocker for our production deployment. I tried reinstalling sqitch and currently I have sqitch v1.3.1 on my mac.

theory commented 1 year ago

Have you tried removing and re-installing Sqitch?

bhawnatyagi commented 1 year ago

Yes, I didn't remove but reinstalled sqitch using brew reinstall sqitch.

theory commented 1 year ago

I have updated my Mac, so tried to run Sqitch, and yeah, it failed due to an upgraded Perl. Reinstall didn't fix it, but removing it then installing it again fixed it.

brew remove sqitch
brew install sqitch --with-postgres-support --with-sqlite-support

I don't think there is anything to do about this: when there is a major Perl upgrade, none of the modules can be considered binary compatible, so Sqitch must be completely reinstalled.

bhawnatyagi commented 1 year ago

I need the reinstallation for snowflake. Does the below command look right to you? brew install sqitch --with-snowflake-support

theory commented 1 year ago

Yep, documented here

bhawnatyagi commented 1 year ago

Hi, I am getting below error while running sqitch status command. Its complaining about tag that has been used to tag one of the change.

sqitch status 'db:snowflake://username:password@account.snowflakecomputing.com/db?Driver=Snowflake;warehouse=wh' Syntax error in sqitch.plan at line 111: Tag "public/procedures/alter_datalake_to_prelanding_insert" contains illegal character /

Could you please help in resolving this issue? What does this error mean?

theory commented 1 year ago

Slashes are not allowed in tags, as of v1.3.1. You will need to remove the slashes from the tag, make it something like public-procedures-alter_datalake_to_prelanding_insert. If you already have deployed this tag to production on an earlier version of Sqitch, you can continue to use that earlier version until you have the chance to fix it, something like:

The --log-only option tells Sqitch to do the revert and deploy without actually running the scripts, so no changes will be made to your database, only to the registry.

bhawnatyagi commented 1 year ago

Thanks, how can I downgrade the sqitch version? I tried using version specifically to downgrade while installing sqitch but it didn't work. Also, how to grab the latest version of sqitch?

We are also trying to do deployment using sqitch docker. However, we are getting below error when we tried running sqitch status command:

output=Database db:snowflake://<account-name>/<db_name>?Driver=Snowflake;warehouse=<wh>;pwd=<pwd>;UID=<user>;role=<Role> has not been initialized for Sqitch. What does this error mean? How can we resolve this issue?
theory commented 1 year ago

It means you haven't deployed a change to that database before, so it does not yet have a registry schema.

bhawnatyagi commented 1 year ago

Oh but we have deployed changes to this database before. The database that we are using is production database. Any idea what could be wrong or how can I debug this issue?

theory commented 1 year ago

My guess is you're not connecting to the database you think you are, or else that the user or role you're using does not have the necessary access.

pchilds commented 7 months ago

Why is this considered completed? Instead of making breaking changes every major version upgrade it is currently still breaking every version upgrade.

theory commented 7 months ago

Mainly because this repository is for the Docker image, not the Homebrew formula. Does sqitchers/homebrew-sqitch#61 correspond to the problem you're seeing?