Skip to content

Can't run Flutter on NFS (flock reports "Bad file descriptor") #6549

Closed

Description

@droundy

Steps to Reproduce

I expect you may have difficulty reproducing this, but I run into the following error when running flutter:

$ flutter
flock: 3: Bad file descriptor

The error happens at line 35 of the flutter shell script, which tries to take a lock using the flock utility. This is on a debian stable computer, and I have no experience using flock with bash, and haven't been able to debug it. I can make flutter work fine by changing the preceding line such that the if statement fails and a lock is not taken.

I presume file descriptor 3 is supposed to be created by line 50, which reads:

) 3< $PROG_NAME

but don't care to learn enough bash to figure out why it is not working, particularly as I have a workaround. But it does seem worth fixing, to make flutter work for folks who aren't comfortable editing a bash script.

Logs

Can't do this since flutter fails. Unless I disable the lock, in which case it works fine.

Flutter Doctor

Again, not relevant.

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Oct 27, 2016
  2. abarth commented on Oct 27, 2016

    @abarth
    Contributor
  3. Hixie commented on Oct 27, 2016

    @Hixie
    Contributor

    What version of bash?

  4. droundy commented on Oct 27, 2016

    @droundy
    Author

    $ bash --version
    GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
    Copyright (C) 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

  5. Hixie commented on Oct 27, 2016

    @Hixie
    Contributor

    Can you add the indicated line below to your flutter shell script in the indicated position and tell me everything that prints when you run flutter doctor?

    ...
    (
      if hash flock 2>/dev/null; then
        stat "$PROG_NAME"                   # ADD THIS LINE
        flock 3 # ensures that we don't simultaneously update Dart in multiple parallel instances
        # some platforms (e.g. Mac) don't have flock or any reliable alternative
      fi
    ...
  6. droundy commented on Oct 27, 2016

    @droundy
    Author

    $ bash --version
    GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
    Copyright (C) 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html

    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

    On Wed, Oct 26, 2016 at 8:29 PM Ian Hickson [email protected]
    wrote:

    What version of bash?

    —
    You are receiving this because you authored the thread.
    Reply to this email directly, view it on GitHub
    #6549 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe-auth/AAIZKWqeM4fgrkS9uGnegdr2ViIQ50fQks5q4BqigaJpZM4Kh0pW
    .

  7. droundy commented on Oct 28, 2016

    @droundy
    Author
    $ bin/flutter
      File: ‘/home/droundy/src/flutter/bin/flutter’
      Size: 2236        Blocks: 8          IO Block: 1048576 regular file
    Device: 27h/39d Inode: 43385868    Links: 1
    Access: (0755/-rwxr-xr-x)  Uid: ( 1137/ droundy)   Gid: (  100/   users)
    Access: 2016-10-28 12:17:36.788721252 -0700
    Modify: 2016-10-28 12:18:09.808504939 -0700
    Change: 2016-10-28 12:18:09.808504939 -0700
     Birth: -
    flock: 3: Bad file descriptor
    
  8. droundy commented on Oct 28, 2016

    @droundy
    Author

    It just occurred to me that this is in an NFS-mounted directory, and I know NFS has some differences in locking. Flutter works fine in /tmp, which is tmpfs. So I guess maybe you can somehow identify that NFS is in use and avoid flock in that case?

  9. Hixie commented on Oct 28, 2016

    @Hixie
    Contributor

    I agree that NFS and locking don't do well, but I wouldn't have expected "Bad file descriptor"...

  10. added this to the milestone on Feb 27, 2017
  11. droundy commented on Oct 31, 2017

    @droundy
    Author

    Any chance that a fix for this could go in, so I could use flutter in my home directory over nfs? My current fix is to edit bin/flutter to change 'if hash flock...' to have a misspelling in flock, so that it doesn't use flock, which fails on nfs. I'm not sure what a proper fix would be, not being an expert in the use of flock.

  12. Hixie commented on Dec 20, 2017

    @Hixie
    Contributor

    The problem seems to be that NFS doesn't support exclusive locking on a file descriptor opened in read-only mode, because it wants to write in order to lock the file.

  13. Hixie commented on Dec 20, 2017

    @Hixie
    Contributor

    We could just ignore errors from flock, I guess... if you replace the flock 3 line with flock 3 || true, does it work for you?

  14. changed the title [-]flock 3: Bad file descriptor[/-] [+]Can't run Flutter on NFS (flock reports "Bad file descriptor")[/+] on Dec 20, 2017
  15. self-assigned this
    on Dec 20, 2017
  16. Hixie commented on Jan 6, 2018

    @Hixie
    Contributor

    Possible workaround in #13955

  17. Hixie commented on Jan 10, 2018

    @Hixie
    Contributor

    Please let me know if that didn't fix it.

  18. droundy commented on Jan 19, 2018

    @droundy
    Author
  19. Hixie commented on Jan 19, 2018

    @Hixie
    Contributor

    Awesome, thanks! Good luck with Flutter!

  20. added a commit that references this issue on Oct 16, 2018
  21. added 2 commits that reference this issue on Oct 17, 2018
  22. github-actions commented on Sep 4, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  23. locked as resolved and limited conversation to collaborators on Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

toolAffects the "flutter" command-line tool. See also t: labels.waiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions