Homebrew is extremely slow on my machine

Hi! I have a Linux machine, and all homebrew commands run extremely slowly on it.

For example, I used the time command to check how long brew --version would take, and here are the results (formatted for human readability):

real 23 minutes 53.609 seconds
user 0 minutes 0.813 seconds
sys 0 minutes 0.454 seconds

Essentially, it took approximately 24 minutes simply to run brew --version. How can I debug why homebrew is being slow on my system in general?

1 Like

How long does brew --prefix take?

Pretty fast actually!

real 0 min 0.015 sec
user 0 min 0.012s sec
sys 0 min 0.000 sec

In that case it’s ruby that’s slow. Do you use the system ruby for anything apart from homebrew?

Not really. Just to ensure that I am being completely transparent, I am not the owner of the device. This is actually an enterprise system of which I am a user. So, I cannot confirm that ruby isn’t being used elsewhere.

However, the system has multiple machines to connect to via ssh (user profiles are synchronized on all systems), and the issue with ruby seems to happen on all of the systems.

I installed homebrew locally for my user because I do not have sudo permissions.

Please report the output of brew config and the output of ruby --version being sure to use the same Ruby executable reported by brew config.

brew config output:

HOMEBREW_VERSION: 2.2.10
ORIGIN: https://github.com/Homebrew/brew
HEAD: 48a1637b24a0c329905a981f4cff547c7fa47943
Last commit: 7 days ago
Core tap ORIGIN: https://github.com/Homebrew/linuxbrew-core
Core tap HEAD: a8d4d17a0960340e466ded1f57cee22b4425b0c0
Core tap last commit: 5 hours ago
HOMEBREW_PREFIX: /home/nik312123/.linuxbrew
HOMEBREW_CELLAR: /home/nik312123/.linuxbrew/Cellar
HOMEBREW_CACHE: /home/nik312123/.cache/Homebrew
HOMEBREW_LOGS: /home/nik312123/.cache/Homebrew/Logs
HOMEBREW_REPOSITORY: /home/nik312123/.linuxbrew/Homebrew
CPU: quad-core 64-bit skylake
Homebrew Ruby: 2.6.3 => /home/nik312123/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: 6.0 build 600
Git: 2.17.1 => /usr/bin/git
Curl: 7.58.0 => /usr/bin/curl
Kernel: Linux 4.15.0-88-generic x86_64 GNU/Linux
OS: Ubuntu 18.04.4 LTS (bionic)
Host glibc: 2.27
/usr/bin/gcc: 7.4.0
glibc: N/A
gcc: N/A
xorg: N/A

/home/nik312123/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby --version output:

ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

How long do each of those two commands take to run?

brew config:
real 27 min 40.695 sec
user 0 min 2.138 sec
sys 0 min 1.823 sec

/home/nik312123/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby --version:
real 0 min 3.577 sec
user 0 min 0.002 sec
sys 0 min 0.000 sec

The timing for checking the ruby version seems to vary sometimes, though.

I timed it again just now, and I got the following result:

/home/nik312123/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby --version :
real 0 min 58.484 sec
user 0 min 0.017 sec
sys 0 min 0.004 sec

One minute to run ruby --version is definitely a problem. If you apt install ruby, how long does ruby --version take with that executable? Is there anything unusual about your computer system? What type of file system are you using, and is it a network mounted file system or a physical disk?

I can’t install via apt because I don’t have sudo permissions.

There is a locally installed version ruby on the system, but it is only ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]

The following is the output when executing /usr/bin/ruby --version (the one mentioned above)
real 0 min 0.014 sec
user 0 min 0.006 sec
sys 0 min 0.004 sec

As mentioned above, this isn’t my system. I am a user in this school enterprise system. I access the system through SSH. How can I check whether it is a network-mounted file system or physical disk?

df -T should show you all the mount types. My guess is that your home directory is mounted on NFS which either is just plain slow over the network link, or isn’t implementing some kind of system call correctly and ruby / homebrew is hitting a timeout.

It is using nfs4 as per the below line of partially redacted output:

xxx-xx-xx.xxx.xxx.edu:/mnt/data/homes/nik312123 nfs4 1749503616 1060197120 689306496 61% /home/nik312123

There is some important information I forgot to mention that might be important. My apologies for the lapse in memory.

Other commands are not nearly as slow. Also, I had homebrew installed on the machine at another earlier point, and it was at normal speed then. However, I had to uninstall it due to the size limitation of 1 GB of files per user folder.

Recently, I cleaned out personal files that were no longer being used and reinstalled it. Are there any other tests I can do to try and fix what is going on?

I also managed to install ruby locally using the instructions here.

Here is the result of the time for that:

real 0 min 0.013 sec
user 0 min 0.006 sec
sys 0min 0.006 sec

Here is also the output of brew doctor:

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don’t worry or file an issue; just ignore this. Thanks!

Warning: Unbrewed header files were found in /usr/local/include.
If you didn’t put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
/usr/local/include/python3.6/pygame/_camera.h
/usr/local/include/python3.6/pygame/_pygame.h
/usr/local/include/python3.6/pygame/_surface.h
/usr/local/include/python3.6/pygame/bitmask.h
/usr/local/include/python3.6/pygame/camera.h
/usr/local/include/python3.6/pygame/fastevents.h
/usr/local/include/python3.6/pygame/font.h
/usr/local/include/python3.6/pygame/freetype.h
/usr/local/include/python3.6/pygame/mask.h
/usr/local/include/python3.6/pygame/mixer.h
/usr/local/include/python3.6/pygame/palette.h
/usr/local/include/python3.6/pygame/pgarrinter.h
/usr/local/include/python3.6/pygame/pgbufferproxy.h
/usr/local/include/python3.6/pygame/pgcompat.h
/usr/local/include/python3.6/pygame/pgopengl.h
/usr/local/include/python3.6/pygame/pygame.h
/usr/local/include/python3.6/pygame/scrap.h
/usr/local/include/python3.6/pygame/surface.h
/usr/local/include/thrift/TApplicationException.h
/usr/local/include/thrift/TDispatchProcessor.h
/usr/local/include/thrift/TLogging.h
/usr/local/include/thrift/TOutput.h
/usr/local/include/thrift/TProcessor.h
/usr/local/include/thrift/TToString.h
/usr/local/include/thrift/Thrift.h
/usr/local/include/thrift/async/TAsyncBufferProcessor.h
/usr/local/include/thrift/async/TAsyncChannel.h
/usr/local/include/thrift/async/TAsyncDispatchProcessor.h
/usr/local/include/thrift/async/TAsyncProcessor.h
/usr/local/include/thrift/async/TAsyncProtocolProcessor.h
/usr/local/include/thrift/async/TConcurrentClientSyncInfo.h
/usr/local/include/thrift/async/TEvhttpClientChannel.h
/usr/local/include/thrift/async/TEvhttpServer.h
/usr/local/include/thrift/c_glib/config.h
/usr/local/include/thrift/c_glib/processor/thrift_dispatch_processor.h
/usr/local/include/thrift/c_glib/processor/thrift_processor.h
/usr/local/include/thrift/c_glib/protocol/thrift_binary_protocol.h
/usr/local/include/thrift/c_glib/protocol/thrift_binary_protocol_factory.h
/usr/local/include/thrift/c_glib/protocol/thrift_protocol.h
/usr/local/include/thrift/c_glib/protocol/thrift_protocol_factory.h
/usr/local/include/thrift/c_glib/server/thrift_server.h
/usr/local/include/thrift/c_glib/server/thrift_simple_server.h
/usr/local/include/thrift/c_glib/thrift.h
/usr/local/include/thrift/c_glib/thrift_application_exception.h
/usr/local/include/thrift/c_glib/thrift_struct.h
/usr/local/include/thrift/c_glib/transport/thrift_buffered_transport.h
/usr/local/include/thrift/c_glib/transport/thrift_buffered_transport_factory.h
/usr/local/include/thrift/c_glib/transport/thrift_framed_transport.h
/usr/local/include/thrift/c_glib/transport/thrift_framed_transport_factory.h
/usr/local/include/thrift/c_glib/transport/thrift_memory_buffer.h
/usr/local/include/thrift/c_glib/transport/thrift_server_socket.h
/usr/local/include/thrift/c_glib/transport/thrift_server_transport.h
/usr/local/include/thrift/c_glib/transport/thrift_socket.h
/usr/local/include/thrift/c_glib/transport/thrift_transport.h
/usr/local/include/thrift/c_glib/transport/thrift_transport_factory.h
/usr/local/include/thrift/concurrency/BoostThreadFactory.h
/usr/local/include/thrift/concurrency/Exception.h
/usr/local/include/thrift/concurrency/FunctionRunner.h
/usr/local/include/thrift/concurrency/Monitor.h
/usr/local/include/thrift/concurrency/Mutex.h
/usr/local/include/thrift/concurrency/PlatformThreadFactory.h
/usr/local/include/thrift/concurrency/PosixThreadFactory.h
/usr/local/include/thrift/concurrency/StdThreadFactory.h
/usr/local/include/thrift/concurrency/Thread.h
/usr/local/include/thrift/concurrency/ThreadManager.h
/usr/local/include/thrift/concurrency/TimerManager.h
/usr/local/include/thrift/concurrency/Util.h
/usr/local/include/thrift/config.h
/usr/local/include/thrift/cxxfunctional.h
/usr/local/include/thrift/processor/PeekProcessor.h
/usr/local/include/thrift/processor/StatsProcessor.h
/usr/local/include/thrift/processor/TMultiplexedProcessor.h
/usr/local/include/thrift/protocol/TBase64Utils.h
/usr/local/include/thrift/protocol/TBinaryProtocol.h
/usr/local/include/thrift/protocol/TCompactProtocol.h
/usr/local/include/thrift/protocol/TDebugProtocol.h
/usr/local/include/thrift/protocol/TJSONProtocol.h
/usr/local/include/thrift/protocol/TMultiplexedProtocol.h
/usr/local/include/thrift/protocol/TProtocol.h
/usr/local/include/thrift/protocol/TProtocolDecorator.h
/usr/local/include/thrift/protocol/TProtocolException.h
/usr/local/include/thrift/protocol/TProtocolTap.h
/usr/local/include/thrift/protocol/TVirtualProtocol.h
/usr/local/include/thrift/qt/TQIODeviceTransport.h
/usr/local/include/thrift/qt/TQTcpServer.h
/usr/local/include/thrift/server/TConnectedClient.h
/usr/local/include/thrift/server/TNonblockingServer.h
/usr/local/include/thrift/server/TServer.h
/usr/local/include/thrift/server/TServerFramework.h
/usr/local/include/thrift/server/TSimpleServer.h
/usr/local/include/thrift/server/TThreadPoolServer.h
/usr/local/include/thrift/server/TThreadedServer.h
/usr/local/include/thrift/thrift-config.h
/usr/local/include/thrift/transport/PlatformSocket.h
/usr/local/include/thrift/transport/TBufferTransports.h
/usr/local/include/thrift/transport/TFDTransport.h
/usr/local/include/thrift/transport/TFileTransport.h
/usr/local/include/thrift/transport/THttpClient.h
/usr/local/include/thrift/transport/THttpServer.h
/usr/local/include/thrift/transport/THttpTransport.h
/usr/local/include/thrift/transport/TPipe.h
/usr/local/include/thrift/transport/TPipeServer.h
/usr/local/include/thrift/transport/TSSLServerSocket.h
/usr/local/include/thrift/transport/TSSLSocket.h
/usr/local/include/thrift/transport/TServerSocket.h
/usr/local/include/thrift/transport/TServerTransport.h
/usr/local/include/thrift/transport/TShortReadTransport.h
/usr/local/include/thrift/transport/TSimpleFileTransport.h
/usr/local/include/thrift/transport/TSocket.h
/usr/local/include/thrift/transport/TSocketPool.h
/usr/local/include/thrift/transport/TTransport.h
/usr/local/include/thrift/transport/TTransportException.h
/usr/local/include/thrift/transport/TTransportUtils.h
/usr/local/include/thrift/transport/TVirtualTransport.h
/usr/local/include/thrift/transport/TZlibTransport.h

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn’t put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .pc files:
/usr/local/lib/pkgconfig/thrift-nb.pc
/usr/local/lib/pkgconfig/thrift-qt.pc
/usr/local/lib/pkgconfig/thrift-qt5.pc
/usr/local/lib/pkgconfig/thrift-z.pc
/usr/local/lib/pkgconfig/thrift.pc
/usr/local/lib/pkgconfig/thrift_c_glib.pc

Warning: Your Homebrew’s prefix is not /home/linuxbrew/.linuxbrew.
Some of Homebrew’s bottles (binary packages) can only be used with the default
prefix (/home/linuxbrew/.linuxbrew).
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew’s GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience while you are running this unsupported configuration.

Here is how long brew doctor took:

real 66 min 15.419 sec
user 0 min 4.469 sec
sys 0 min 4.207 sec

That’s ruby --version again I guess?

That is correct. That is the time it took to run ruby --version on a user-installed version of ruby (2.6.5) installed as per the link provided, which is much faster than ruby --version for the ruby packaged with homebrew that took 3 seconds on one test above and nearly a minute on another test above.

Was the original homebrew installed by you, or root?