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

Problems with .sh script permissions #1840

Closed
canxin121 opened this issue Mar 27, 2024 · 10 comments · Fixed by #1842
Closed

Problems with .sh script permissions #1840

canxin121 opened this issue Mar 27, 2024 · 10 comments · Fixed by #1842
Labels
bug Something isn't working

Comments

@canxin121
Copy link
Contributor

canxin121 commented Mar 27, 2024

Describe the bug

If the project is created under windows, then the sh script permissions cannot be changed to 0o755, and when these under-privileged sh scripts are uploaded to github and executed when running flutter build ios in the MacOs Runner using Github Actions, the build process crashes due to the sh script permission issue and crashes.

(Ps. There seems to be a big problem with Flutter's logging system, when flutter build ios crashes due to sh permissions issues, Flutter incorrectly reports Building a deployable iOS app requires a selected Development Team with a Please ensure that a Development Team is selected by. )

Steps to reproduce

  1. In windows, use flutter_rust_bridge_codegen create new_app to create a new demo project.
  2. Upload the project to github, then use github action to build a ios ipa.

The workflow file used above: https://github.com/canxin121/new_app/blob/main/.github/workflows/build.yml

Logs

with --verbose

2024-03-27T14:51:56.1985690Z /Users/runner/work/myapp/myapp/ios/Pods/../.symlinks/plugins/rust_lib_violet/ios/../cargokit/build_pod.sh: line 52: /Users/runner/work/myapp/myapp/rust_builder/cargokit/run_build_tool.sh: Permission denied
2024-03-27T14:51:56.1985690Z /Users/runner/work/myapp/myapp/ios/Pods/../.symlinks/plugins/rust_lib_violet/ios/../cargokit/build_pod.sh:第52行:/ Users/runner/work/myapp/myapp/rust_builder/cargokit/run_build_tool.sh:权限被拒绝

without --verbose:

Run flutter build ios --release --no-codesign
Warning: Building for device with codesigning disabled. You will have to manually codesign before deploying to device.
Building com.example.hw2 for device (ios-release)...
Updating minimum iOS deployment target to 12.0.
Upgrading Podfile
Running pod install...                                           1,183ms
Running Xcode build...                                          
Xcode build done.                                            4.9s
Failed to build iOS app
════════════════════════════════════════════════════════════════════════════════
Building a deployable iOS app requires a selected Development Team with a 
Provisioning Profile. Please ensure that a Development Team is selected by:
  1- Open the Flutter project's Xcode target with
       open ios/Runner.xcworkspace
  2- Select the 'Runner' project in the navigator then the 'Runner' target
     in the project settings
  3- Make sure a 'Development Team' is selected under Signing & Capabilities > Team. 
     You may need to:
         - Log in with your Apple ID in Xcode first
         - Ensure you have a valid unique Bundle ID
         - Register your device with your Apple Developer Account
         - Let Xcode automatically provision a profile for your app
  4- Build or run your project again

For more information, please visit:
  https://flutter.dev/docs/get-started/install/macos#deploy-to-ios-devices

Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════
Encountered error while building for device.
Error: Process completed with exit code 1.

Expected behavior

sh scripts should be secured with executable permissions before they are used.

OS

Windows and MacOS

@canxin121 canxin121 added the bug Something isn't working label Mar 27, 2024
Copy link

welcome bot commented Mar 27, 2024

Hi! Thanks for opening your first issue here! 😄

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 27, 2024

Hmm, IIRC you do need to select a provisioning profile when developing ios flutter. Does it work if we just follow what Flutter says and select a provisioning profile?

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Mar 27, 2024
@canxin121
Copy link
Contributor Author

Hmm, IIRC you do need to select a provisioning profile when developing ios flutter. Does it work if we just follow what Flutter says and select a provisioning profile?

I don't have a mac, but theoretically with --no-signcode there should be no need for a provisioning profile. Without using flutter_rust_bridge, it's true that building ipa can be done without it. Or with using this https://github.com/project-violet/violet to run action, it's also build ipa successfully without provisioning profile. I've confirmed this by forking it and run it mannuly.

@canxin121
Copy link
Contributor Author

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 27, 2024

Hmm, what about --verbose to flutter build and see the logs, maybe it will reveal something.

@canxin121
Copy link
Contributor Author

Hmm, what about --verbose to flutter build and see the logs, maybe it will reveal something.嗯, --verbose 来 flutter build 并查看日志怎么样,也许它会揭示一些东西。

I found something very strange.

https://github.com/canxin121/myapp
https://github.com/canxin122/myapp
These are two myapp repos from two different accounts with identical files except for .git. The second link is from a fork, and the first repo is from copying all the files (except .git) from the second repo.
44d8c75bd6dfb6dec928cec8da79149d

But now there is a very strange situation, the same GitHub action workflow builds flutter's ios ipa in the second repo, but the first repo gives me the following error:
ca1db04a20062701e87d5f8ca8581299

Then I tried to use --mirror to duplicate the second repo exactly, and it builds the ios ipa fine.

I will try to use --verbose right now.

@canxin121
Copy link
Contributor Author

Hmm, what about --verbose to flutter build and see the logs, maybe it will reveal something.嗯, --verbose 来 flutter build 并查看日志怎么样,也许它会揭示一些东西。

This is the action for a failed build and --verbose: https://github.com/canxin121/myapp/actions/runs/8453774701/job/23157246140; this is the action for a successful build and --verbose: https://github.com/canxin122/myapp/actions/runs/8453759931/job/23157195246

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 27, 2024

The failed one says:

2024-03-27T14:51:56.1985690Z /Users/runner/work/myapp/myapp/ios/Pods/../.symlinks/plugins/rust_lib_violet/ios/../cargokit/build_pod.sh: line 52: /Users/runner/work/myapp/myapp/rust_builder/cargokit/run_build_tool.sh: Permission denied

So it looks like your sh is not executable (wrong permission)

@canxin121
Copy link
Contributor Author

The failed one says:失败者说道:

2024-03-27T14:51:56.1985690Z /Users/runner/work/myapp/myapp/ios/Pods/../.symlinks/plugins/rust_lib_violet/ios/../cargokit/build_pod.sh: line 52: /Users/runner/work/myapp/myapp/rust_builder/cargokit/run_build_tool.sh: Permission denied2024-03-27T14:51:56.1985690Z /Users/runner/work/myapp/myapp/ios/Pods/../.symlinks/plugins/rust_lib_violet/ios/../cargokit/build_pod.sh:第52行:/ Users/runner/work/myapp/myapp/rust_builder/cargokit/run_build_tool.sh:权限被拒绝

So it looks like your sh is not executable (wrong permission)所以看起来你的 sh 不可执行(错误的权限)

It's really a file permissions issue, when my project is created under windows, the permissions on run_build_tool.sh can't be changed to 0o755, which results in run_build_tool.sh being uploaded to git and then having too low of permissions under the MacOS Runner in github action cannot be executed.

This can indeed be fixed by adding the line chmod a+x "$BASEDIR/run_build_tool.sh" to build_pod.sh .
https://github.com/canxin121/myapp/commit/b2a809c7c83b14981963c802ffe108363cf00ebf

@canxin121 canxin121 mentioned this issue Mar 28, 2024
4 tasks
@canxin121 canxin121 changed the title 'flutter build ios --release --no-codesign' don't work without a Provisioning Profile; Problems with .sh script permissions Mar 28, 2024
knopp pushed a commit to irondash/cargokit that referenced this issue Apr 3, 2024
Origin issue: fzyzcjy/flutter_rust_bridge#1840
Origin pr: fzyzcjy/flutter_rust_bridge#1842

Simple problem description: if you create a new flutter_rust project in
windows, the sh script is automatically created, but the executable
permissions cannot be set. When moving this project to macOS and
executing `flutter build ios` to build ipa files the process crashes due
to insufficient sh script permissions.

This permission problem can be circumvented by `sh script.sh` rather
than `script.sh`

As verified by Github Action's macOS Runner, the modified cargokit works
fine for building ipa apps using the flutter_rust project created on
windows.

[Action
Link](https://github.com/canxin121/new_app_test/actions/runs/8466294309)
@fzyzcjy fzyzcjy closed this as completed Apr 4, 2024
Copy link
Contributor

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 issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2024
@fzyzcjy fzyzcjy removed the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Jun 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants