buo / homebrew-cask-upgrade

A command line tool for upgrading every outdated app installed by Homebrew Cask
MIT License
2.4k stars 90 forks source link

Error: No such file or directory @ rb_sysopen - /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/addressable-2.8.0/data/unicode.data #205

Closed tiancheng92 closed 2 years ago

tiancheng92 commented 2 years ago
# input
brew cu

# output
Error: No such file or directory @ rb_sysopen - /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/addressable-2.8.0/data/unicode.data
# input
brew doctor

# output
Your system is ready to brew.
# input
brew config

# output
HOMEBREW_VERSION: 3.4.11-53-g34dd8e3
ORIGIN: https://github.com/Homebrew/brew
HEAD: 34dd8e305789a5433d345a29b03a4d4f3a568d1e
Last commit: 4 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 0f98d77858de1aa1738d1d09ad4d226114255cbe
Core tap last commit: 65 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_BAT: set
HOMEBREW_CASK_OPTS: []
HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS: 1
HOMEBREW_CLEANUP_MAX_AGE_DAYS: 1
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_FORCE_BREWED_CURL: set
HOMEBREW_FORCE_BREWED_GIT: set
HOMEBREW_MAKE_JOBS: 8
HOMEBREW_NO_ANALYTICS: set
HOMEBREW_NO_AUTO_UPDATE: set
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 13.1.6 build 1316
Git: 2.36.1 => /opt/homebrew/opt/git/bin/git
Curl: 7.83.1 => /opt/homebrew/opt/curl/bin/curl
macOS: 12.4-arm64
CLT: 13.4.0.0.1.1651278267
Xcode: N/A
Rosetta 2: false
mikelorant commented 2 years ago

Issue looks to be caused by this commit.

https://github.com/Homebrew/brew/commit/fb8a4e565836e33f2195ff49eaf10535d8bb78a0

PR https://github.com/Homebrew/brew/pull/13292

mikelorant commented 2 years ago

My fix so far has been this:

cp -R /usr/local/lib/ruby/gems/2.6.0/gems/addressable-2.8.0/data /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/addressable-2.8.0
liukaiwen0422 commented 2 years ago

I don't have dir /usr/local/lib/ruby/gems/2.6.0 I have dir /usr/local/lib/ruby/gems/3.10 how to fix this error,plz?

mikelorant commented 2 years ago

Likely just replace the 2.6.0 with 3.10.

liukaiwen0422 commented 2 years ago

Likely just replace the 2.6.0 with 3.10.

But there is no folder with path like 2.6

mikelorant commented 2 years ago

Otherwise just get the unicode.data file from here:

https://github.com/sporkmonger/addressable/tree/main/data

It is only this file that needs to be in that directory.

liukaiwen0422 commented 2 years ago

yes! it's work,thanks

Otherwise just get the unicode.data file from here:

https://github.com/sporkmonger/addressable/tree/main/data

It is only this file that needs to be in that directory.

ondrejfuhrer commented 2 years ago

@tiancheng92 did this work for you as well? Can we close this then?

mikelorant commented 2 years ago

I think this is an issue that will impact others. This may require an update to this addon.

electriquo commented 2 years ago

i had the same issue and resolved it by

mkdir /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/addressable-2.8.0/data/
wget https://raw.githubusercontent.com/sporkmonger/addressable/main/data/unicode.data -O /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/addressable-2.8.0/data/unicode.data
ondrejfuhrer commented 2 years ago

I think this is an issue that will impact others. This may require an update to this addon.

@mikelorant What kind of update you have in mind? We're using "standard" brew commands to update the casks, therefore to me it seems is an issue with homebrew itself?

It doesn't happen to me, so it's probably related to some specific conditions? It's hard to "fix" if we can't reproduce :-(

z0rc commented 2 years ago

We're using "standard" brew commands to update the casks

Is there a way to find what brew command triggers this error? I have the same issue with brew cu, but regular brew cli works okay.

ondrejfuhrer commented 2 years ago

@z0rc I don't think there is an easy way. Does it happen immediately or you already get some output before it errors out?

z0rc commented 2 years ago

@ondrejfuhrer Almost immediately after exec, no additional output.

% brew cu
Error: No such file or directory @ rb_sysopen - /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/addressable-2.8.0/data/unicode.data

Tested also brew cu --verbose --no-brew-update, but additional options didn't have an effect, error remains as is. brew cu --help works okay though.

kovalchik commented 2 years ago

I am also receiving this error. The same as @z0rc, there's also no additional output. cu --help does also work for me.

dbeenlee commented 2 years ago

yes! it's work,thanks

yes! it's work,thanks

ondrejfuhrer commented 2 years ago

@z0rc & @kovalchik can you try running brew vendor-install ruby if that fixes it maybe? Since there is no input then it means something is off with the initialisation of this extension, but I can't find anything even closely related to the issue described.

kovalchik commented 2 years ago

@ondrejfuhrer brew vendor-install ruby completed successfully, but didn't fix the issue. 😞

ondrejfuhrer commented 2 years ago

Didn't meant to close it immediately. @kovalchik can you try brew update and then brew cu if it works now? I managed to reproduce the issue and might have found the culprit. Not sure though if it didn't break anything else 😆 🤞

kovalchik commented 2 years ago

@ondrejfuhrer That worked! After running brew update, brew cu ran and completed successfully. 🙌

z0rc commented 2 years ago

I also confirm that this fixed the issue. Thanks!

samford commented 2 years ago

From a quick glance, this issue is likely due to needing to run #install_bundler_gems at some point. We usually call Homebrew.install_bundler_gems! in commands that use parts of brew that involve external gems (like addressable) but I forgot to handle that in the aforementioned PR. I imagine it's affecting your code because cask/audit requires livecheck/livecheck which now requires addressable.

Anyone who's seeing this error has already run a dev-cmd before (i.e., my commit isn't in a brew release yet), so they should be able to safely resolve the error by running brew install-bundler-gems.

I'm working on a follow-up PR on our end but, unfortunately, I have to create a separate PR beforehand to modify the behavior of #install_bundler_gems (to be able to safely call it in livecheck). Once that's done and I've added Homebrew.install_bundler_gems! in related parts of brew (livecheck, bump, cask/audit), it may resolve this issue for you.

If you want to resolve this quickly or err on the safe side, you can add a Homebrew.install_bundler_gems! call in your code (somewhere early on, where you're setting things up). If you search the brew codebase for install_bundler_gems!, you'll find some example usage.

ondrejfuhrer commented 2 years ago

Thank you for the context @samford ! I actually removed direct require of cask (which was causing the issue) which probably happens anyways somewhere as the code works without any issues (or at least I haven't spotted any).

That being said, it's great to have the context on this to understand what happened 🙂

ondrejfuhrer commented 2 years ago

I'll consider this issue being resolved then 🙂 thank you all for your help investigating this.

samford commented 2 years ago

After investigating further, we just needed to vendor more of addressable. We were already vendoring the lib directory by default but we also need the data directory, where unicode.data is found. I didn't see the error when I was testing because my addressable directory had all the files from when it was installed. We temporarily reverted the aforementioned commit but a fix will be included when it's reinstated, so this shouldn't require changes on your end (edit: now reinstated with gem-related fixes).

At this point, users can resolve the error by running brew update.