Brew: Brew fails if flock is not implemented: -e:1:in `flock': Function not implemented (Errno::ENOSYS)

Created on 9 Oct 2016  路  20Comments  路  Source: Linuxbrew/brew

_From @ningzhai on October 9, 2016 10:23_

As problem issued in the title.
Following is how I installed the linuxbrew:

git clone https://github.com/Linuxbrew/brew.git linuxbrew
echo "#linuxbrew" >>~/.bash_profile
echo "export PATH=$PWD/linuxbrew/bin:\$PATH" >>~/.bash_profile
echo "export MANPATH=$PWD/linuxbrew/share/man:\$MANPATH" >>~/.bash_profile
echo "export INFOPATH=$PWD/linuxbrew/share/info:\$INFOPATH" >>~/.bash_profile
PATH=$(getconf PATH)
source ~/.bash_profile

When I want to install the first software through brew, that is "brew install hello", I got following error:

-e:1:in `flock': Function not implemented (Errno::ENOSYS)
        from -e:1
Error: Another active Homebrew process is already in progress.
Please wait for it to finish or terminate it to continue.
Error: Failed to install vendor Ruby.

Somebody can help me ?

_Copied from original issue: Linuxbrew/legacy-linuxbrew#1110_

bug help wanted

All 20 comments

@ningzhai Which operating system are you running? Please report the output of brew config

Hi,
I have also encountered this error. There is my configuration: $ brew config

HOMEBREW_VERSION: 1.0.7-8-gd5f4afad7
ORIGIN: https://github.com/Linuxbrew/brew.git
HEAD: d5f4afad76b31a61b9cf22e77da71be2a9ceb892
Last commit: 11 hours ago
Core tap ORIGIN: https://github.com/Linuxbrew/homebrew-core
Core tap HEAD: b7ca722c79156fb190df3daaf04ebf069a44ec18
Core tap last commit: 8 hours ago
HOMEBREW_PREFIX: /share/backup/zhujie/.linuxbrew
HOMEBREW_REPOSITORY: /share/backup/zhujie/.linuxbrew
HOMEBREW_CELLAR: /share/backup/zhujie/.linuxbrew/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://linuxbrew.bintray.com
CPU: octa-core 64-bit dothan
Homebrew Ruby: 2.3.1 => /ifs1/ST_META/USER/wangzhifeng1/software/ruby/bin/ruby
Clang: N/A
Git: 2.10.0 => /home/zhujie/workdir/software/git/bin/git
Perl: /share/app/perl-5.22.0/bin/perl
Python: /share/app/python-2.7.10/bin/python
Ruby: /ifs1/ST_META/USER/wangzhifeng1/software/ruby/bin/ruby
Java: 1.8.0_102
Kernel: Linux 2.6.32-504.16.2.el6.x86_64 x86_64 GNU/Linux
OS: CentOS release 6.6 (Final)
OS glibc: 2.12
OS gcc: 4.4.7
Linuxbrew glibc: N/A
Linuxbrew gcc: N/A
Linuxbrew xorg: N/A

Please help me!
Thanks very much! :)

Do you know what type of file system you're on? It doesn't appear to support the flock operation.

-e:1:in `flock': Function not implemented (Errno::ENOSYS)

Please report the output of

mount | grep ifs1

@rwhogg Brew fails if flock is not implemented for that file system. It should fail with a better error message. brew doctor should check for this. It should fall back to an alternative locking system when flock is not available. (all wish list and notes to self)

$ mount | grep ifs1
isilon1.sz.local:/ifs/data/ST_META on /ifs1/ST_META type nfs (rw,tcp,soft,intr,lookupcache=positive,vers=3,sloppy,addr=_._._._)

It is nfs file system.

Your two options are

  1. enable support for flock on your NFS server
  2. hack up Linuxbrew to use an alternative lock other than flock and submit a PR

@LovelornPig @macmanes You can change the lock dir to a filesystem that supports flock like for example /tmp/$USER/linuxbrew by hacking up Library/Homebrew/config.rb. There's no environment variable to configure this setting. 馃槙 The default value is

HOMEBREW_LOCK_DIR = HOMEBREW_PREFIX/"var/homebrew/locks"

See https://github.com/Linuxbrew/brew/blob/master/Library/Homebrew/config.rb#L27

@michaelmhoffman suggested that you make $(brew --prefix)/var/homebrew/locks a symlink to a file system that supports flock. 馃槑

Note that there are some packages that do not respect the specified locking dir and try to lock files in Cellar. An example of this is glibc-2.19 and Cellar/glibc/2.19/lib/locale.

Moving and linking this directory to a file system that supports locking and rerunning brew postinstall glibc solves this issue, but there may be other packages that do the same.

Thanks for the heads up, Michael. brew doctor should check that the FS of $(brew --prefix) and $(brew --cellar) supports flock. A PR would be welcome if you're interested.

The way my current computing cluster is set up is that there is only 1 GiB of storage available with flock support and more without. Cellar is too large to be moved to the first file system, so just checking for support wouldn't solve the issue for me.

So my setup is that both $(brew --prefix) and $(brew --cellar) are on /noflock/somewhere (due to storage constraints) and I created a /flock/lockdir to link $(brew --prefix)/var/homebrew/locks to.

Hence, brew doctor checking whether $(brew --cellar) supports flock would fail in my case. Ideally, I would like to see no file locks in $(brew --cellar) but only $(brew --prefix)/var/homebrew/locks.

Sorry, I don't follow, Michael. On which file system(s) is $(brew --prefix) and $(brew --cellar) installed, and do they support flock? I'm proposing that brew doctor checks that both of those file systems supports flock.

@sjackman sorry for the confusion, updated above

No worries. Thanks for the clarification. I understand now.

You can put $HOMEBREW_PREFIX and $HOMEBREW_CELLAR on different file systems, though it's not typical, so that $HOMEBREW_PREFIX/var/homebrew/locks is on your small 1 GiB file system that supports flock. I prefer your solution though, of making $HOMEBREW_PREFIX/var/homebrew/locks a symlink to a file system that supports flock.

brew doctor should check that $HOMEBREW_PREFIX/var/homebrew/locks supports flock.

We can't unfortunately ensure that the software installed by Linuxbrew doesn't use flock on files in that formula's prefix. That's entirely up to that software and out of our control.

I see that error in our centos6 docker image, running on my mac.

==> Pouring git-2.14.3.x86_64_linux.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /home/linuxbrew/.linuxbrew/etc/bash_completion.d

Emacs Lisp files have been installed to:
  /home/linuxbrew/.linuxbrew/share/emacs/site-lisp/git
==> Summary
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/git/2.14.3: 1,408 files, 43.2MB
which: no flock in (/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
Initialized empty Git repository in /home/linuxbrew/.linuxbrew/Homebrew/.git/
[linuxbrew@93224d8bf376 ~]$ brew install systemd -svd
which: no flock in (/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/systemd.rb
... 

Is it still successful, despite the error message?
See https://github.com/Linuxbrew/brew/blob/master/Library/Homebrew/utils/lock.sh#L45
It first tries ruby, then flock, then python to lock a file. Any of these should satisfy the requirement. I think that ruby should always be satisfied now, since brew now requires Ruby > 2.3.
Perhaps

  elif [[ -x "$(which flock)" ]]

should be

  elif [[ -x "$(which flock 2>/dev/null)" ]]

Yes it succeeds, and yes that error message needs to be suppressed. I opened a pull request upstream: https://github.com/Homebrew/brew/pull/3381

With brew 1.3.6 the first reported flock error should be fixed. With https://github.com/Homebrew/brew/pull/3381, the stderr message is suppressed, so this will be even better with brew 1.3.7 (which is not released for the moment).

All other flock errors related to specific formulae/packages should be reported upstream, because there is not much we can do about that.

@sjackman I would be in favour of closing this issue.

This issue has come up a few times (three or four times). A brew doctor check would be good to check that the $HOMEBREW_PREFIX/var/homebrew/locks directory implements flock, and if it does not, suggest symlinking this directory to a volume that does implement flock.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iMichka picture iMichka  路  6Comments

thedrow picture thedrow  路  6Comments

dlukes picture dlukes  路  5Comments

randy3k picture randy3k  路  6Comments

rwhogg picture rwhogg  路  5Comments