shorebirdtech / shorebird

Code Push for Flutter and other tools for Flutter businesses.
https://shorebird.dev
Other
1.96k stars 118 forks source link

Seeing `PathNotFoundException` when manually executing `shorebird.dart` #1987

Closed iamdipanshusingh closed 2 weeks ago

iamdipanshusingh commented 2 weeks ago

App ID: a1e18e4d-fe2c-42f9-b92e-24df2eae4127

Description

I'm working on a feature which will the users to use the patch or release commands for multiple platforms from a single command. But getting this OS Error.

Steps To Reproduce

  1. Try running shorebird locally

Expected Behavior

Expecting the command to run without any failures

Screenshots

Screenshot 2024-04-29 at 2 52 57 PM

Additional Context

Additionally, shorebird cli is working fine and as expected when running its public release. Running shorebid.dart (~/StudioProjects/shorebird/packages/shorebird_cli/bin/shorebird.dart) from my app's root folder where pubspec.yaml and shorebird.yaml are located

 mv3-new git:(ds/feat/shorebird) ✗ dart ~/StudioProjects/shorebird/packages/shorebird_cli/bin/shorebird.dart patch -p android,ios --verbose
../../.pub-cache/hosted/pub.dev/pointycastle-3.9.0/lib/macs/cbc_block_cipher_mac.dart:103:46: Warning: Operand of null-aware operation '!' has type 'Padding' which excludes null.
 - 'Padding' is from 'package:pointycastle/api.dart' ('../../.pub-cache/hosted/pub.dev/pointycastle-3.9.0/lib/api.dart').
    var paddingName = _padding != null ? '/${_padding!.algorithmName}' : '';
                                             ^
../../.pub-cache/hosted/pub.dev/pointycastle-3.9.0/lib/macs/cbc_block_cipher_mac.dart:203:7: Warning: Operand of null-aware operation '!' has type 'Padding' which excludes null.
 - 'Padding' is from 'package:pointycastle/api.dart' ('../../.pub-cache/hosted/pub.dev/pointycastle-3.9.0/lib/api.dart').
      _padding!.addPadding(_buf, _bufOff);
      ^
../../.pub-cache/hosted/pub.dev/pointycastle-3.9.0/lib/signers/ecdsa_signer.dart:94:41: Warning: Operand of null-aware operation '!' has type 'Mac' which excludes null.
 - 'Mac' is from 'package:pointycastle/api.dart' ('../../.pub-cache/hosted/pub.dev/pointycastle-3.9.0/lib/api.dart').
      kCalculator = _RFC6979KCalculator(_kMac!, n, _pvkey!.d!, message);
                                        ^
../../.pub-cache/hosted/pub.dev/pointycastle-3.9.0/lib/signers/ecdsa_signer.dart:166:7: Warning: Operand of null-aware operation '!' has type 'Digest' which excludes null.
 - 'Digest' is from 'package:pointycastle/api.dart' ('../../.pub-cache/hosted/pub.dev/pointycastle-3.9.0/lib/api.dart').
      _digest!.reset();
      ^
../../.pub-cache/hosted/pub.dev/pointycastle-3.9.0/lib/signers/ecdsa_signer.dart:167:14: Warning: Operand of null-aware operation '!' has type 'Digest' which excludes null.
 - 'Digest' is from 'package:pointycastle/api.dart' ('../../.pub-cache/hosted/pub.dev/pointycastle-3.9.0/lib/api.dart').
      return _digest!.process(message);
             ^
PathNotFoundException: Cannot open file, path = '/Users/dipanshu/StudioProjects/shorebird/packages/bin/internal/flutter.version' (OS Error: No such file or directory, errno = 2)
#0      _File.throwIfError (dart:io/file_impl.dart:675:7)
#1      _File.openSync (dart:io/file_impl.dart:490:5)
#2      _File.readAsBytesSync (dart:io/file_impl.dart:574:18)
#3      _File.readAsStringSync (dart:io/file_impl.dart:624:18)
#4      ShorebirdEnv.flutterRevision (package:shorebird_cli/src/shorebird_env.dart:65:11)
#5      ShorebirdEnv.flutterDirectory (package:shorebird_cli/src/shorebird_env.dart:76:9)
#6      ShorebirdEnv.shorebirdEngineRevision (package:shorebird_cli/src/shorebird_env.dart:42:9)
#7      PatchArtifact.storageUrl (package:shorebird_cli/src/cache.dart:280:85)
#8      CachedArtifact.update (package:shorebird_cli/src/cache.dart:144:51)
#9      Cache.updateAll (package:shorebird_cli/src/cache.dart:60:22)
<asynchronous suspension>
#10     PatchAndroidCommand.run (package:shorebird_cli/src/commands/patch/patch_android_command.dart:118:5)
<asynchronous suspension>
#11     PatchCommand.run (package:shorebird_cli/src/commands/patch/patch_command.dart:115:11)
<asynchronous suspension>
#12     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#13     ShorebirdCliCommandRunner.runCommand (package:shorebird_cli/src/command_runner.dart:209:20)
<asynchronous suspension>
#14     ShorebirdCliCommandRunner.run (package:shorebird_cli/src/command_runner.dart:124:14)
<asynchronous suspension>
#15     main (file:///Users/dipanshu/StudioProjects/shorebird/packages/shorebird_cli/bin/shorebird.dart:31:5)
<asynchronous suspension>

Running this on flutter: 3.19.6 and dart: 3.3.4

bryanoltman commented 2 weeks ago

You should be running shorebird/bin/shorebird, not shorebird.dart. What are you trying to accomplish by running shorebird.dart instead?

iamdipanshusingh commented 2 weeks ago

@bryanoltman I'm running shorebird/packages/shorebird_cli/bin/shorebird.dart for sure.

ran this command: dart ~/StudioProjects/shorebird/packages/shorebird_cli/bin/shorebird.dart patch -p android,ios

bryanoltman commented 2 weeks ago

Right – you shouldn't be running shorebird.dart. You should run the output of which shorebird, which for me is [parent_dir]/shorebird/bin/shorebird. Is there a reason you're trying to run the dart file itself?

bryanoltman commented 2 weeks ago

You mentioned on Discord that you're working on a feature that will patch ios and android together. Can you talk more about the approach you're taking?

iamdipanshusingh commented 2 weeks ago

Right – you shouldn't be running shorebird.dart. You should run the output of which shorebird, which for me is [parent_dir]/shorebird/bin/shorebird. Is there a reason you're trying to run the dart file itself?

ohhh, didn't know that! Now I know what I was doing wrong 😅 Thanks for letting me know!

iamdipanshusingh commented 2 weeks ago

You mentioned on Discord that you're working on a feature that will patch ios and android together. Can you talk more about the approach you're taking?

I saw, there's a hash function which adds the options in each subcommands. So, I've basically combined all the options from all the subcommands and have put it in the patch command itself.

Now that I have the arguments option in the patch command I'm passing the argParser and argResults to then patch subcommands (like PatchAndroidCommand) along with the hash function in the constructor. Not sure if its a good approach.

Let me know your thoughts on this, and if it can be improved.

closing this issue!