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

When running tauri build, bundle_dmg.sh errors fails to bundle project #3055

Open
joepio opened this issue Dec 10, 2021 · 42 comments
Open

When running tauri build, bundle_dmg.sh errors fails to bundle project #3055

joepio opened this issue Dec 10, 2021 · 42 comments

Comments

@joepio
Copy link
Contributor

joepio commented Dec 10, 2021

Edit: the .dmg files are actually created and function correctly. You can find them in ./target/release/bundle/macos

Describe the bug

When running tauri build, bundle_dmg.sh errors fails to bundle project.
Looking at the error log below, the issue seems to stem from an Apple script not being authorized: execution error: Not authorised to send Apple events to Finder. (-1743)

I tried restarting, upgrading rustc, and running sudo tauri build - didn't help.

Interestingly, tauri dev does work.

To Reproduce

  1. git clone git@github.com:joepio/atomic-data-rust.git
  2. tauri build

Platform and Versions (required):

Operating System - Mac OS, version 12.0.1 X64

Node.js environment
  Node.js - 16.9.1
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - Not installed

Global packages
  npm - 7.21.1
  yarn - 1.22.17

Rust environment
  rustc - 1.57.0
  cargo - 1.57.0

App directory structure
/target
/server
/cli
/.github
/src-tauri
/lib
/.git
/.vscode

App
  tauri.rs - 1.0.0-beta.8 (no lockfile)
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../server/static
  devPath - ../server/static/tauri-splashscreen.html
package.json not found

Additional context

Add any other context about the problem here.

Stack Trace

+ WINX=10
+ WINY=60
+ WINW=500
+ WINH=350
+ ICON_SIZE=128
+ TEXT_SIZE=16
+ FORMAT=UDZO
+ ADD_FILE_SOURCES=()
+ ADD_FILE_TARGETS=()
+ IMAGEKEY=
+ HDIUTIL_VERBOSITY=
+ SANDBOX_SAFE=0
+ SKIP_JENKINS=0
+ MAXIMUM_UNMOUNTING_ATTEMPTS=3
+ POSITION_CLAUSE=
+ HIDING_CLAUSE=
+ [[ - = \- ]]
+ case $1 in
+ VOLUME_NAME='Atomic Server'
+ shift
+ shift
+ case $FORMAT in
+ IMAGEKEY='-imagekey zlib-level=9'
+ [[ - = \- ]]
+ case $1 in
+ POSITION_CLAUSE='set position of item "Atomic Server" to {180, 170}
		'
+ shift
+ shift
+ shift
+ shift
+ case $FORMAT in
+ IMAGEKEY='-imagekey zlib-level=9'
+ [[ - = \- ]]
+ case $1 in
+ APPLICATION_LINK=480
+ APPLICATION_CLAUSE='set position of item "Applications" to {480, 170}
		'
+ shift
+ shift
+ shift
+ case $FORMAT in
+ IMAGEKEY='-imagekey zlib-level=9'
+ [[ - = \- ]]
+ case $1 in
+ WINW=660
+ WINH=400
+ shift
+ shift
+ shift
+ case $FORMAT in
+ IMAGEKEY='-imagekey zlib-level=9'
+ [[ - = \- ]]
+ case $1 in
+ HIDING_CLAUSE='set the extension hidden of item "Atomic Server.app" to true
		'
+ shift
+ shift
+ case $FORMAT in
+ IMAGEKEY='-imagekey zlib-level=9'
+ [[ - = \- ]]
+ case $1 in
+ VOLUME_ICON_FILE=/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg/icon.icns
+ shift
+ shift
+ case $FORMAT in
+ IMAGEKEY='-imagekey zlib-level=9'
+ [[ A = \- ]]
+ [[ -z Atomic Server.app ]]
+++ dirname /Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg/bundle_dmg.sh
++ cd /Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg
++ pwd
+ SCRIPT_DIR=/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg
+ DMG_PATH='Atomic Server_0.28.2_aarch64.dmg'
++ dirname 'Atomic Server_0.28.2_aarch64.dmg'
+ DMG_DIRNAME=.
++ cd .
++ pwd
+ DMG_DIR=/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos
++ basename 'Atomic Server_0.28.2_aarch64.dmg'
+ DMG_NAME='Atomic Server_0.28.2_aarch64.dmg'
+ DMG_TEMP_NAME='/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/rw.Atomic Server_0.28.2_aarch64.dmg'
++ cd 'Atomic Server.app'
++ pwd
+ SRC_FOLDER='/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/Atomic Server.app'
+ [[ .dmg != \.\d\m\g ]]
+ [[ -z Atomic Server ]]
+ BREW_INSTALL=0
+ AUX_PATH=/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg/support
+ '[' 0 -eq 0 ']'
+ test -d /Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg/support
+ [[ -f /Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/Atomic Server.app/.DS_Store ]]
+ echo 'Creating disk image...'
Creating disk image...
+ [[ -f /Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/rw.Atomic Server_0.28.2_aarch64.dmg ]]
+ rm -f '/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/rw.Atomic Server_0.28.2_aarch64.dmg'
+ CUSTOM_SIZE=
+ [[ -n '' ]]
+ '[' 0 -eq 0 ']'
+ hdiutil create -srcfolder '/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/Atomic Server.app' -volname 'Atomic Server' -fs HFS+ -fsargs '-c c=64,a=16,e=16' -format UDRW '/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/rw.Atomic Server_0.28.2_aarch64.dmg'
...............................................................................................
created: /Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/rw.Atomic Server_0.28.2_aarch64.dmg
++ get_size '/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/rw.Atomic Server_0.28.2_aarch64.dmg'
+++ du -s '/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/rw.Atomic Server_0.28.2_aarch64.dmg'
+++ sed -e 's/	.*//g'
++ bytes_size=48224
+++ blocks_to_megabytes 48224
+++ MB_SIZE=25
+++ echo 25
++ echo 25
+ DISK_IMAGE_SIZE=25
+ [[ 0 -eq 1 ]]
+ [[ -n '' ]]
++ expr 25 + 20
+ DISK_IMAGE_SIZE=45
++ hdiutil resize -limits '/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/rw.Atomic Server_0.28.2_aarch64.dmg'
++ awk 'NR=1{print int($1/2048+1)}'
+ MIN_DISK_IMAGE_SIZE=24
+ '[' 24 -gt 45 ']'
+ hdiutil resize -size 45m '/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/rw.Atomic Server_0.28.2_aarch64.dmg'
+ echo 'Mounting disk image...'
Mounting disk image...
+ MOUNT_DIR='/Volumes/Atomic Server'
+ [[ -d /Volumes/Atomic Server ]]
+ echo 'Mounting disk image...'
Mounting disk image...
+ echo 'Mount directory: /Volumes/Atomic Server'
Mount directory: /Volumes/Atomic Server
++ hdiutil attach -readwrite -noverify -noautoopen '/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/macos/rw.Atomic Server_0.28.2_aarch64.dmg'
++ egrep --color=never '^/dev/'
++ sed 1q
++ awk '{print $1}'
+ DEV_NAME=/dev/disk4
+ echo 'Device name:     /dev/disk4'
Device name:     /dev/disk4
+ [[ -n '' ]]
+ [[ -n 480 ]]
+ echo 'making link to Applications dir'
making link to Applications dir
+ test -d '/Volumes/Atomic Server/Applications'
+ ln -s /Applications '/Volumes/Atomic Server/Applications'
+ [[ -n '' ]]
+ [[ -n /Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg/icon.icns ]]
+ echo 'Copying volume icon file '\''/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg/icon.icns'\''...'
Copying volume icon file '/Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg/icon.icns'...
+ cp /Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg/icon.icns '/Volumes/Atomic Server/.VolumeIcon.icns'
+ SetFile -c icnC '/Volumes/Atomic Server/.VolumeIcon.icns'
+ [[ -n '' ]]
++ mktemp -t createdmg.tmp.XXXXXXXXXX
+ APPLESCRIPT_FILE=/var/folders/k1/tynj2xbn5nd12wm5qn3sc4600000gn/T/createdmg.tmp.XXXXXXXXXX.ZJcDOTOg
+ [[ 0 -eq 1 ]]
+ [[ 0 -eq 0 ]]
+ applescript_source
+ '[' 0 -eq 0 ']'
+ cat /Users/joep/dev/github/joepio/atomic-data-rust/target/release/bundle/dmg/support/template.applescript
+ sed -e s/WINX/10/g -e s/WINY/60/g -e s/WINW/660/g -e s/WINH/400/g -e s/BACKGROUND_CLAUSE//g -e s/REPOSITION_HIDDEN_FILES_CLAUSE//g -e s/ICON_SIZE/128/g -e s/TEXT_SIZE/16/g
+ perl -pe 's/POSITION_CLAUSE/set position of item "Atomic Server" to {180, 170}
		/g'
+ perl -pe s/QL_CLAUSE//g
+ perl -pe 's/APPLICATION_CLAUSE/set position of item "Applications" to {480, 170}
		/g'
+ perl -pe 's/HIDING_CLAUSE/set the extension hidden of item "Atomic Server.app" to true
		/'
+ sleep 2
+ echo 'Running AppleScript to make Finder stuff pretty: /usr/bin/osascript "/var/folders/k1/tynj2xbn5nd12wm5qn3sc4600000gn/T/createdmg.tmp.XXXXXXXXXX.ZJcDOTOg" "Atomic Server"'
Running AppleScript to make Finder stuff pretty: /usr/bin/osascript "/var/folders/k1/tynj2xbn5nd12wm5qn3sc4600000gn/T/createdmg.tmp.XXXXXXXXXX.ZJcDOTOg" "Atomic Server"
+ /usr/bin/osascript /var/folders/k1/tynj2xbn5nd12wm5qn3sc4600000gn/T/createdmg.tmp.XXXXXXXXXX.ZJcDOTOg 'Atomic Server'
/var/folders/k1/tynj2xbn5nd12wm5qn3sc4600000gn/T/createdmg.tmp.XXXXXXXXXX.ZJcDOTOg:394:406: execution error: Not authorised to send Apple events to Finder. (-1743)
+ echo 'Failed running AppleScript'
Failed running AppleScript
+ hdiutil detach /dev/disk4
"disk4" ejected.
+ exit 64
Error: failed to bundle project

Caused by:
    Shell Scripting Error:`error running bundle_dmg.sh`

 app:spawn Command "/Users/joep/.config/yarn/global/node_modules/@tauri-apps/cli/bin/tauri-cli" failed with exit code: 1 +1ms
@lucasfernog
Copy link
Member

Is this happening when running on CI? If so you need an env variable: #2567

@joepio
Copy link
Contributor Author

joepio commented Dec 10, 2021

Thanks for the quick reply. it's happening locally on my m1 macbook

@Avineak
Copy link

Avineak commented Dec 18, 2021

@lucasfernog
I am facing similar issues with my m1 mac.
It just tries to open finder and then fails with same error.

info: running bundle_dmg.sh
Error: failed to bundle project

Caused by:
    Shell Scripting Error:`error running bundle_dmg.sh, try running with --verbose to see command output`
   

@probablykasper
Copy link
Member

Running into this as well, can confirm that CI=true npm run tauri build works

This should also be fixed when #1731 is done

@qqpann
Copy link

qqpann commented Feb 17, 2022

When setting CI=true, it just stops generating the DMG file. Doesn't seem to be a reasonable fix on mac. 🤔

@probablykasper
Copy link
Member

It works fine for me, so if you're actually not getting a DMG file then that sounds like a separate issue

@lucasfernog
Copy link
Member

You should get a DMG file, though a not so good looking one :( we'll need to refactor the DMG bundle script to fix this.

@jamesb93
Copy link

I get this error when trying to run pnpm tauri build. Same issue with finder access.

@lorenzolewis
Copy link
Member

FYI, tracing this back into create-dmg/create-dmg#113.

Mojave introduced a new plist value that is required for Apple Script (used in create-dmg) to work with other applications (i.e. Finder).

Maybe we could introduce an OS version check to see if it's Mojave or later and dynamically choose to tack on the CI tag to skip using AppleScript as a workaround until (if) upstream fixes?

@lucasfernog
Copy link
Member

I wish we could stop using applescript and use something like https://github.com/LinusU/node-appdmg but it's a lot of work to translate that one to Rust.

@LucienGab
Copy link

LucienGab commented May 12, 2022

when i run CI=true npm run tauri build it still returns the error what am i doing wrong?

@gregpalaci
Copy link

#3055 (comment)
same here mac m1

@jonasmerlin
Copy link

Same here on Mac M1

@hjmallon
Copy link

There are various threads talking about similar stuff to this. In one of them it recommended to open Photos.app and press 'Get Started' (I haven't used it before on this mac). That actually worked for some reason. 🤷

@jasonhibbs
Copy link

Commenting because opening Photos.app worked for me on an M1 MacBook Pro…

Before opening Photos.app…

Running bundle_dmg.sh
       Error failed to bundle project: error running bundle_dmg.sh: error running bundle_dmg.sh: `failed to run […]/tauri-app/src-tauri/target/release/bundle/dmg/bundle_dmg.sh`
error Command failed with exit code 1.

After…

Running bundle_dmg.sh
    Finished 2 bundles at:
        […]/tauri-app/src-tauri/target/release/bundle/macos/tauri-app.app
        […]/tauri-app/src-tauri/target/release/bundle/dmg/tauri-app_0.0.0_aarch64.dmg

@kholbekj
Copy link

For me, Photos.app did not accomplish anything on M2 Macbook Air, CI=true option does work!

@ruanimal
Copy link

ruanimal commented Mar 1, 2023

It seems is macOS permission related problem, run “tarui build ” manual for the first time, problem solved.

@rekby
Copy link

rekby commented Mar 10, 2023

I had same problem.
Simple run Photos not help to me.

It was successed after manual run build script (bundle_dmg.sh from targer/release folder) and it build image. Then I unmount own builded image from finder.

@itsanji
Copy link

itsanji commented Mar 15, 2023

I had same problem with Core i7 Mac ( Ventura 13.1 ).
Node version is 16.14.2 and had error with both yarn and npm.
Error was shown but .App file and .dmg file was built.
I tested both and look like it running without any error (yet?)

@thinksamwp
Copy link

I managed to solve this issue by running pnpm tauri build directly in the macOS terminal.

@raunakdoesdev
Copy link

The issue for me was that the previously built image was open and bundle_dmg.sh couldn't overwrite it because the old app was running (permission error). Silly problem!

@slimsag
Copy link

slimsag commented May 19, 2023

Run pnpm tauri build --verbose to get the underlying cause. In my case:

hdiutil: create failed - Operation not permitted
could not access /Volumes/Sourcegraph/Sourcegraph.app - Operation not permitted

Then forcibly remove the volume:

sudo rm -rf /Volumes/Sourcegraph/Sourcegraph.app

And that won't fully resolve it (not sure why); you need to restart.

@maqi1520
Copy link

maqi1520 commented Jun 6, 2023

Same here on Mac M1

But I turned off the updater, it works well

"updater": {
      "active": false,
      "endpoints": ["https://maqi1520.github.io/mdx-editor/install.json"],
      "dialog": true,
      "pubkey": ""
    },

@dukeeagle
Copy link

Tried all the above options on macOS and still receiving the same error! Is this still an issue for anyone else?

@dukeeagle
Copy link

dukeeagle commented Jul 1, 2023

I fixed it! I think the latest version of macOS is responsible here.

error when building with yarn in verbose mode yarn run tauri build -v:

hdiutil: create failed - Operation not permitted
could not access /Volumes/App/App.app - Operation not permitted

Fixed by enabling "Full Disk Access" in System Settings for Terminal! (and VSCode for its internal terminal)

@raunakdoesdev
Copy link

raunakdoesdev commented Jul 2, 2023 via email

@leon-do
Copy link

leon-do commented Jul 6, 2023

Screenshot 2023-07-06 at 6 28 37 PM

I had to enable full disk access. Might be a better & safer way.

@kernelsoe
Copy link

CI=true pnpm tauri build works for me! 👍

@tungtouch
Copy link

tungtouch commented Aug 2, 2023

i tried it, simple to fix sudo -E npm run tauri build --verbose (you will need to use sudo -E in order to expose environment variables.)
make sure disk not full

@jackiealex
Copy link

see your Mac Finder sidebar, you will see something mounted, just delete it, everyting will be ok

@JameelKhan9
Copy link

JameelKhan9 commented Sep 26, 2023

Having the same error, but a different flavour from the looks of the other comments. Just posting my flavour here for anyone that is looking to investigate and wants a clearer picture maybe:

+ hdiutil create -srcfolder /Users/jameel/Documents/GitHub/tauriapp-desktop-app/src-tauri/target/release/bundle/macos/tauriapp.app -volname tauriapp -fs HFS+ -fsargs '-c c=64,a=16,e=16' -format UDRW /Users/jameel/Documents/GitHub/tauriapp-desktop-app/src-tauri/target/release/bundle/macos/rw.tauriapp_0.0.0_aarch64.dmg
hdiutil: create failed - Read-only file system
       Error [tauri_cli_node] failed to bundle project: error running bundle_dmg.sh
 ELIFECYCLE  Command failed with exit code 1.

Seems to be hdiutil permissions related, but using sudo, full disk access, mount permissions didn't help.

@otwm
Copy link

otwm commented Nov 16, 2023

same error

+ hdiutil create -srcfolder /Users/otwm/WebstormProjects/playground/tauri-app2/src-tauri/target/release/bundle/macos/tauri-app2.app -volname tauri-app2 -fs HFS+ -fsargs '-c c=64,a=16,e=16' -format UDRW /Users/otwm/WebstormProjects/playground/tauri-app2/src-tauri/target/release/bundle/macos/rw.tauri-app2_0.0.0_aarch64.dmg
hdiutil: create failed - 읽기 전용 파일 시스템
       Error [tauri_cli_node] failed to bundle project: error running bundle_dmg.sh
       ```
       

@lroolle
Copy link

lroolle commented Nov 16, 2023

‌‌In my situation, the Terminal.app, which has been granted Full Disk Access, functions correctly. On the other hand, the Alacritty.app error in running bundle_dmg.sh

@musabgultekin
Copy link

These steps solved my issue:

  • Give finder access to terminal/vscode (Macos will popup when you first build)
  • Remove src-tauri/target folder.
  • Close and open the terminal/vscode
  • Build again

@kodmanyagha
Copy link

This is about vscode's terminal problem. In mac's terminal there isn't problem.

@tk-dev
Copy link

tk-dev commented Dec 21, 2023

This worked for me on macOS Sonoma:

Give Terminal.app the permissions to control Finder.app:
Go to System-Settings -> Privacy & Security -> Automation
There select Terminal and below enable the switch Finder.

@theodesp
Copy link

This worked for me on macOS Sonoma:

Give Terminal.app the permissions to control Finder.app: Go to System-Settings -> Privacy & Security -> Automation There select Terminal and below enable the switch Finder.

This solution worked for me as well.

taikulawo added a commit to yetpocket/cls-verge that referenced this issue Mar 8, 2024
fix github action build error
tauri-apps/tauri#3055
@AaronWard
Copy link

Error failed to bundle project: error running bundle_dmg.sh

A mix of the recommended fixes worked for me (for M1 Macbook):

  • Make sure settings in automation section have Finder enabled:
Screenshot 2024-03-22 at 11 20 10
  • Deleted src-tauri/target folder
  • Make sure any other previous/problematic bundles are ejected / deleted or are not currently running
  • Close and restart the terminal
  • npm run tauri build

@kristoferfannar-ks
Copy link

kristoferfannar-ks commented Jun 20, 2024

I'm having the same error
specs:

  • mac m3 on sonoma 14.5
  • cargo v1.78
  • tauri 1.6.0

using cargo tauri build --target aarch64-apple-darwin --verbose

+ echo 'Running AppleScript to make Finder stuff pretty: /usr/bin/osascript "/var/folders/rm/zcn1js9j6sx82wt_82xm5b9h0000gn/T/createdmg.tmp.XXXXXXXXXX.wHuns9Qx3o" "<project>"'
Running AppleScript to make Finder stuff pretty: /usr/bin/osascript "/var/folders/rm/zcn1js9j6sx82wt_82xm5b9h0000gn/T/createdmg.tmp.XXXXXXXXXX.wHuns9Qx3o" "<project>"
+ /usr/bin/osascript /var/folders/rm/zcn1js9j6sx82wt_82xm5b9h0000gn/T/createdmg.tmp.XXXXXXXXXX.wHuns9Qx3o '<project>'
/var/folders/rm/zcn1js9j6sx82wt_82xm5b9h0000gn/T/createdmg.tmp.XXXXXXXXXX.wHuns9Qx3o:85:89: execution error: Finder got an error: Application isn’t running. (-600)
+ echo 'Failed running AppleScript'
Failed running AppleScript
+ hdiutil detach /dev/disk4
"disk4" ejected.
+ exit 64
       Error [tauri_cli] failed to bundle project: error running bundle_dmg.sh

from a quick search it seems that this is a MacOS error, and the short term solution is to restart the machine, while the long term solution is to report it to apple and wait.

@maxktz
Copy link

maxktz commented Jun 23, 2024

Same here on Mac M1

@kyteidev
Copy link

kyteidev commented Jul 8, 2024

For me it happens randomly. I just build my app again until it works.

@dondxniel
Copy link

So, at first i was running cargo tauri build, but since that failed a couple times and after reading some of the suggestions on how to bye pass the permission problems (some of the suggestions didn't work for me), I just ran sudo cargo tauri build and it worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📬Proposal
Development

No branches or pull requests