Skip to content

Instantly share code, notes, and snippets.

@SteveBenner
Forked from yiufung/truecrypt_fix.bash
Last active September 27, 2024 11:02
Show Gist options
  • Save SteveBenner/10938596 to your computer and use it in GitHub Desktop.
Save SteveBenner/10938596 to your computer and use it in GitHub Desktop.
Homebrew fix - unexpected files and libs from ‘osxfuse'
#!/usr/bin/env ruby
#
# Homebrew fix 1 - osxfuse dylibs
#
# original solutions: https://gist.github.com/aaronzirbes/3239033
# https://gist.github.com/trinitronx/5437061
#
# Fixes the following:
#
# > Warning: Unbrewed dylibs were found in /usr/local/lib.
#
# > Unexpected dylibs:
# > /usr/local/lib/libmacfuse_i32.2.dylib
# > /usr/local/lib/libmacfuse_i64.2.dylib
# > /usr/local/lib/libosxfuse_i32.2.dylib
# > /usr/local/lib/libosxfuse_i64.2.dylib
#
# > Warning: Unbrewed .la files were found in /usr/local/lib.
#
# > Unexpected .la files:
# > /usr/local/lib/libosxfuse_i32.la
# > /usr/local/lib/libosxfuse_i64.la
#
# > Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
#
# > Unexpected .pc files:
# > /usr/local/lib/pkgconfig/osxfuse.pc
LIBS = %w[
libmacfuse_i32.2.dylib
libosxfuse_i32.2.dylib
libosxfuse_i64.2.dylib
libmacfuse_i64.2.dylib
libosxfuse_i32.la
libosxfuse_i64.la
pkgconfig/osxfuse.pc
].map {|libname| "/usr/local/lib/#{libname}" }
TRUECRYPT_LIB_PATH = '/Applications/TrueCrypt.app/Contents/Resources/Library'
abort "This fix appears to be unnecessary! Diagnose issues by running 'brew doctor'." unless LIBS.detect do |lib|
!(File.exist?("#{TRUECRYPT_LIB_PATH}/#{File.basename(lib)}") && File.symlink?(lib))
end
begin
require 'fileutils'
rescue # perform ops using shell
`mkdir -p #{TRUECRYPT_LIB_PATH}` unless Dir.exist? TRUECRYPT_LIB_PATH
LIBS.each do |lib|
libdir = "#{TRUECRYPT_LIB_PATH}/#{lib}"
abort "Failed to copy #{lib} to #{libdir}" unless `cp -v #{lib} #{libdir}`
abort "Failed to remove #{lib}" unless `rm -v #{lib}`
end
else # perform ops using Ruby
FileUtils.mkdir_p TRUECRYPT_LIB_PATH unless Dir.exist? TRUECRYPT_LIB_PATH
FileUtils.cp LIBS, TRUECRYPT_LIB_PATH, :verbose => true
FileUtils.rm LIBS, :verbose => true
ensure
LIBS.each {|lib| File.symlink "#{TRUECRYPT_LIB_PATH}/#{File.basename(lib)}", lib }
end
puts "Homebrew 'osxfuse dylib' fix applied successfully! Latest version at: https://gist.github.com/SteveBenner/10938596"
puts `brew prune && brew doctor`
@SteveBenner
Copy link
Author

@lukePeavey Unfortunately I no longer use Truecrypt, ever since official support for the software was abruptly discontinued in what seems a highly odd turn of events… Perhaps someday I’ll return to using it, but you should know that the software itself is no longer maintained.

In fact…

This problem is caused by TrueCrypt falling out of date with newer OS X systems, and it’s nothing to be worried about; rest assured that the script is _completely non-destructive_, and it will gently exit out if it detects something wrong or if the fix isn’t necessary. The code isn’t documented, but I can easily explain what’s going on: in a nutshell, Homebrew throws a fit because all of a sudden it expects these library files to be somewhere specific in TrueCrypt, and they aren’t.

Actually though, brew doctor is doing what it's supposed to do—diagnose everything from critical errors to tiny discrepancies (Homebrew is really smart software). TrueCrypt is just out of date, and all the script does is to move the files over _into_ TrueCrypt, to where Homebrew expects to find them. It then creates symbolic links _back to where they came from_, meaning your system effectively sees the files as being in two places now. I see no way for this to break TrueCrypt, but if anything goes wrong, you can obviously just remove the symlinks and put the library files back, reversing the whole process.

@Swiss-Mac-User
Copy link

This script unfortunately does not work anymore on macOS 12 Monterey using Homebrew version 3.4.0…

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `initialize':
No such file or directory @ rb_sysopen - /usr/local/lib/libmacfuse_i32.2.dylib (Errno::ENOENT)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment