Permission denied on build script

After having a lot of fun getting Jekyll performing amazing with Pages, I thought I’d have a play around with a Blazor WASM app. My build.sh is copied from the Pages guide

#!/bin/sh
curl -sSL https://dot.net/v1/dotnet-install.sh > dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh -c 5.0 -InstallDir ./dotnet5
./dotnet5/dotnet --version
./dotnet5/dotnet publish -c Release -o output

But then the build fails, the relevant part of the build log is

09:01:07.061    Executing user command: ./build.sh
09:01:07.062    /opt/build/bin/build: line 39: ./build.sh: Permission denied
09:01:07.063    Failed: build command exited with code: 126

If I just copy out the lines of the build file and paste it into the build command field, it works/builds/deploys just fine (ie curl -sSL https://dot.net/v1/dotnet-install.sh > dotnet-install.sh && chmod +x dotnet-install.sh && ./dotnet-install.sh -c 5.0 -InstallDir ./dotnet5 && ./dotnet5/dotnet --version && ./dotnet5/dotnet publish -c Release -o output)

I’m very much a hobbyist dev, so I’m 100% okay with it being a PEBKAC on my end, but it’d be nice to have it a little more contained in a build script :slight_smile:

(edit: I have no idea how to set the tag for the post to #CloudflarePages )

I’m pretty sure it’s this. The file probably doesn’t have 755 permissions so all can execute.

What system are you running this on?

I’m not sure what Cloudflare Pages specifically runs on, *nix of some sort, which is why it’d need the chmod +x in the build script. I don’t think Git maintains the permissions natively? The only way would be to change the build command from ./build.sh to chmod +x build.sh && ./build.sh

1 Like

Ah, now it’s making sense. You’re not running that locally.

I don’t know how Pages executes that script. All I can suggest is you ask around on the Workers Discord server. Maybe the devs there can figure this out.

1 Like

chmod +x build.sh && ./build.sh worked for me!

3 Likes

You can store the execute in git using git add --chmod=+x build.sh.

3 Likes