fermyon / homebrew-tap

Fermyon's Homebrew Tap
Apache License 2.0
2 stars 9 forks source link

Error upgrading, if a plugin has been installed #9

Closed mikkelhegn closed 1 year ago

mikkelhegn commented 1 year ago

Trying to upgrade the brew package, I get this error:

Last 15 lines from /Users/mikkel/Library/Logs/Homebrew/spin/post_install.04.spin:
2023-09-03 21:31:25 +0200

/opt/homebrew/Cellar/spin/1.4.2/bin/spin
plugins
update

Error: Error updating Git repo at /opt/homebrew/etc/fermyon-spin/plugins/.spin-plugins: From https://github.com/fermyon/spin-plugins
   c6da386..2aaac40  main       -> origin/main
error: Your local changes to the following files would be overwritten by merge:
    manifests/check-for-update/check-for-update.json
Please commit your changes or stash them before you merge.
Aborting

Warning: The post-install step did not complete successfully

Spin got upgraded, but not the plugins. If I remove the .spin-plugins directory and run a reinstall it completes successfully.

kate-goldenring commented 1 year ago

I wasn't able to reproduce yes, sadly. I succeeded in installing a non default plugin and then reinstalling.

$ brew install fermyon/tap/spin
$ spin plugin install check-for-update
$ brew uninstall fermyon/tap/spin
# don't clean up plugins
$ brew install fermyon/tap/spin
# succeeds and still has added check-for-update plugin
$ spin plugins list
  check-for-update 0.0.1
  check-for-update 0.1.0 [installed]
  cloud 0.1.0
  cloud 0.1.1
  cloud 0.1.2 [installed]
  js2wasm 0.1.0
  js2wasm 0.2.0
  js2wasm 0.3.0
  js2wasm 0.4.0
  js2wasm 0.5.0
  js2wasm 0.5.1 [installed]
  pluginify 0.6.0
  py2wasm 0.1.0
  py2wasm 0.1.1
  py2wasm 0.2.0
  py2wasm 0.3.0 [installed]

I did confirm that that a git status shows all items in .spin-plugins as modified -- which i am not sure why this is the case -- but that didn't cause issues with a fresh install. I also modified one of the manifests and found that fresh install succeeded and persisted those changes. It seems like from the error, a conflicting change to check-for-updates.json was made locally. Did you update it at all?

This is the line in Spin where the error is being thrown.

mikkelhegn commented 1 year ago

It seems like from the error, a conflicting change to check-for-updates.json was made locally. Did you update it at all?

Not sure what you're asking here? :-)

Could it be a git config on my machine?

tpmccallum commented 1 year ago

Just sharing my instance of this (similar) error:

==> /usr/local/Cellar/spin/1.4.2/bin/spin plugins update
Last 15 lines from /Users/tpmccallum/Library/Logs/Homebrew/spin/post_install.04.spin:
2023-09-07 08:56:00 +1000

/usr/local/Cellar/spin/1.4.2/bin/spin
plugins
update

Error: Error updating Git repo at /usr/local/etc/fermyon-spin/plugins/.spin-plugins: From https://github.com/fermyon/spin-plugins
   c6da386..2aaac40  main       -> origin/main
error: Your local changes to the following files would be overwritten by merge:
    manifests/check-for-update/check-for-update.json
Please commit your changes or stash them before you merge.
Aborting

Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall fermyon/tap/spin
==> Summary
🍺  /usr/local/Cellar/spin/1.4.2: 5 files, 47.4MB, built in 20 seconds
==> Running `brew cleanup spin`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /usr/local/Cellar/spin/1.4.1... (5 files, 47.4MB)
Removing: /Users/tpmccallum/Library/Caches/Homebrew/spin--1.4.1.tar.gz... (17MB)

I did not change the internals of manifests/check-for-update/check-for-update.json. But am getting the same message as @mikkelhegn.

kate-goldenring commented 1 year ago

Looks like homebrew is modifying the permissions of the files (to make them executable), making git declare files as modified:

Kates-MacBook-Pro :: etc/fermyon-spin/plugins » ls -lh .spin-plugins 
total 48
-rwxr-xr-x  1 kagold  admin    11K Sep  6 17:15 LICENSE
-rwxr-xr-x  1 kagold  admin   4.1K Sep  6 17:15 README.md
-rwxr-xr-x  1 kagold  admin   422B Sep  6 17:15 create-manifest.sh
drwxr-xr-x  7 kagold  admin   224B Sep  6 17:15 example
drwxr-xr-x  4 kagold  admin   128B Sep  6 17:15 json-schema
drwxr-xr-x  7 kagold  admin   224B Sep  6 17:15 manifests
Kates-MacBook-Pro :: etc/fermyon-spin/plugins » ls -lh ~/Library/Application\ Support/spin/plugins/.spin-plugins 
total 48
-rw-r--r--  1 kagold  staff    11K Sep  5 20:23 LICENSE
-rw-r--r--  1 kagold  staff   4.1K Sep  5 20:23 README.md
-rwxr-xr-x  1 kagold  staff   422B Sep  5 20:23 create-manifest.sh
drwxr-xr-x  7 kagold  staff   224B Sep  5 20:23 example
drwxr-xr-x  4 kagold  staff   128B Sep  5 20:23 json-schema
drwxr-xr-x  7 kagold  staff   224B Sep  5 20:23 manifests
tpmccallum commented 1 year ago

The contents of my /usr/local/etc/fermyon-spin/plugins/.spin-plugins/manifests/check-for-update/check-for-update.json file is:

{
    "name": "check-for-update",
    "description": "Command to verify if you're using latest spin CLI or not.",
    "homepage": "https://github.com/ThorstenHans/spin-plugin-check-for-update",
    "version": "0.0.1",
    "spinCompatibility": ">=0.4",
    "license": "Apache-2.0",
    "packages": [
      {
        "os": "linux",
        "arch": "aarch64",
        "url": "https://github.com/ThorstenHans/spin-plugin-check-for-update/releases/download/v0.0.1/check-for-update-v0.0.1-linux-aarch64.tar.gz",
        "sha256": "28b283edfdf7534c7651fae05c880367d37eb1a1d27d35422bc25d108f86ef37"
      },
      {
        "os": "linux",
        "arch": "amd64",
        "url": "https://github.com/ThorstenHans/spin-plugin-check-for-update/releases/download/v0.0.1/check-for-update-v0.0.1-linux-amd64.tar.gz",
        "sha256": "1c9106547ee7290aff5289a7e3e7062e9c073492b92155c357c378f83714b196"
      },
      {
        "os": "macos",
        "arch": "aarch64",
        "url": "https://github.com/ThorstenHans/spin-plugin-check-for-update/releases/download/v0.0.1/check-for-update-v0.0.1-macos-aarch64.tar.gz",
        "sha256": "919fc5e33f193747317ef5c3f24a7e0e309b57e8f25f9df77ae214727679b778"
      },
      {
        "os": "macos",
        "arch": "amd64",
        "url": "https://github.com/ThorstenHans/spin-plugin-check-for-update/releases/download/v0.0.1/check-for-update-v0.0.1-macos-amd64.tar.gz",
        "sha256": "d44d7f84769b93bb2a3e1c0cae56cb37be30ea261ed6c8a2b98df2643f96f872"
      },
      {
        "os": "windows",
        "arch": "amd64",
        "url": "https://github.com/ThorstenHans/spin-plugin-check-for-update/releases/download/v0.0.1/check-for-update-v0.0.1-windows-amd64.tar.gz",
        "sha256": "d581eeaaa2dd00fa5ac6fc9ee517dd059a033471fd6a8ad3219085c246eab602"
      }
    ]
}
kate-goldenring commented 1 year ago

we could add a git reset --hard to formula to remove the modification that homebrew has applied to make the files executable, but i am looking to see if there is something we can configure in homebrew around this

kate-goldenring commented 1 year ago

here is our problematic line: https://github.com/fermyon/homebrew-tap/blob/8dadb42927826312a111241116d1a8f837dbda03/Formula/spin.rb#L41C5-L41C46

mikkelhegn commented 11 months ago

I just had this issue when trying to upgrade to 1.5 today. Is that expected, given a fix was merged?

kate-goldenring commented 11 months ago

@mikkelhegn did you uninstall the pre-fix 1.4.2 and reinstall post fix? Otherwise, if using the pre-fix 1.4.2, an upgrade to 1.5 should show this error as the file permissions were modified. I just verified that i was able to upgrade without any issues from post-fix 1.4.2

mikkelhegn commented 11 months ago

I don't know, but let's say that was it :-)