Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Command failed: hdiutil detach (reopen #142) #229

Open
elneruda opened this issue Aug 2, 2023 · 5 comments
Open

Error: Command failed: hdiutil detach (reopen #142) #229

elneruda opened this issue Aug 2, 2023 · 5 comments

Comments

@elneruda
Copy link

elneruda commented Aug 2, 2023

I'm currently encountering the same issue #142 running the following configuration:

  • Github Action runs-on: macos-13
  • orchestrating the release with fastlane
  • running a tiny lane:
lane :dmg do 
  Dir.chdir("../") do
      sh("npm install -g appdmg")
      sh("appdmg fastlane/dmg.json MyApp.dmg")
  end
end
Error: Command failed: hdiutil detach /Volumes/MyApp
hdiutil: detach failed - No such file or directory

This issue has also been reported on in the thread by me and Othyn: #142 (comment)
I haven't found a way to re-open issue so I'm opening this one.

@elneruda elneruda changed the title Error: Command failed: hdiutil detach Error: Command failed: hdiutil detach (reopen #142) Aug 2, 2023
@BoykoAlex
Copy link

Any workarounds? Happens on osx 12 runners for me as well...

@n-elie
Copy link

n-elie commented Nov 13, 2023

It happens for me from time to time. For example here: https://github.com/metgem/metgem_releases/actions/runs/6831611094/job/18581300522

[18/21] Unmounting temporary image...        [FAIL]
[19/21] Removing temporary image...          [ OK ]
[20/21] Removing target image...             [ OK ]

Error: Command failed: hdiutil detach /Volumes/MetGem
hdiutil: detach failed - No such file or directory


Usage: file [-bcCdEhikLlNnprsSvzZ0] [--extension] [--mime-encoding]
            [--mime-type] [-e <testname>] [-F <separator>]  [-f <namefile>]
            [-m <magicfiles>] [-M magicfiles] [-P <parameter=value>] [--exclude-quiet]
            <file> ...
       file -C [-m <magicfiles>]
       file [--help]
Try `file --help' for more information.

@AoEiuV020
Copy link

I have encountered this issue as well, but it seems to occur randomly. Despite using the same code and packaging script, I have been unable to reproduce the problem consistently. After an extended period of use, it has only occurred once.
image

@yuvalkarmi
Copy link

@LinusU looks like sometimes the volume is already unmounted and this attempts to unmount it, which throws an error.
Here's the fix that worked for me (including patch file here): check if the volume exists before attempting to unmount:

In hdiutil.js:


exports.detach = function (path, cb) {
  const args = ['detach', path];

  let attempts = 0;
  function attemptDetach(err) {
    attempts += 1;

    // Check if the path exists before attempting to detach
    util.pathExists(path, (existsErr, exists) => {
      if (existsErr || !exists) {
        // the path doesn't exist, so we don't need to detach
        cb(null);
        return;
      }

      if (err && (err.exitCode === 16 || err.code === 16) && attempts <= 8) {
        setTimeout(() => {
          util.sh('hdiutil', args, attemptDetach);
        }, 1000 * Math.pow(2, attempts - 1));
      } else {
[appdmg+0.6.6.patch](https://github.com/LinusU/node-appdmg/files/14017142/appdmg%2B0.6.6.patch)

        cb(err);
      }
    });
  }

  // Initial attempt to detach
  util.sh('hdiutil', args, attemptDetach);
};

@BoykoAlex
Copy link

If the code above fixes the issue what is expected to fold it in? a PR? (@LinusU)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants