Could not find the pub cache. No `LOCALAPPDATA` environment variable exists.
Flutter-Sdk:3.37.0-1.0.pre-314 • channel main Dart-Sdk:3.10.0-247.0.dev The project on GitHub:flutter_scene-master\examples\flutter_app Cmd:flutter run -d windows --enable-impeller -v Note:Modify according to the first issue in Issues,otherwise, there will be another error message. Setting up LOCALAPPDATA and PUB_CACHE still results in an error. Error message prompt:
[ ] To reproduce run:
[ ] E:\FlutterSDK\flutter\bin\cache\dart-sdk\bin\dart
--packages=E:\FlutterProject\flutter-demo01\flutter_scene-master\examples\flutter_app.dart_tool\package_con
fig.json
E:\FlutterProject\flutter-demo01\flutter_scene-master\examples\flutter_app.dart_tool\hooks_runner\example_a
pp\3a3c4b6b38b994297fc01180a6f477e7\hook.dill
--config=E:\FlutterProject\flutter-demo01\flutter_scene-master\examples\flutter_app.dart_tool\hooks_runner
example_app\3a3c4b6b38b994297fc01180a6f477e7\input.json
[ ] stderr:
[ ] Unhandled exception:
[ ] Exception: Failed to run flutter_scene_importer:import command in build hook (exit
code 255):
[ ] STDERR: Could not find the pub cache. No LOCALAPPDATA environment variable exists.
[ ] Consider setting the PUB_CACHE variable manually.
Code:
final importerResult = Process.runSync( dartExec.toFilePath(), [ 'run', '--enable-experiment=native-assets', 'flutter_scene_importer:import', '--input', inputFilePath, '--output', outDir.uri.resolve(outputFileName).toFilePath(), '--working-directory', buildInput.packageRoot.toFilePath(), ], ); if (importerResult.exitCode != 0) { throw Exception( 'Failed to run flutter_scene_importer:import command in build hook (exit code ${importerResult.exitCode}):\nSTDERR: ${importerResult.stderr}\nSTDOUT: ${importerResult.stdout}'); }
Attempt: I printed out the parameters which are equivalent to the following command:
dart run --enable-experiment=native-assets flutter_scene_importer:import --input ../assets_src/fcar.glb --output E:\FlutterProject\flutter-demo01\flutter_scene-master\examples\flutter_app\build\models\fcar.model --working-directory E:\FlutterProject\flutter-demo01\flutter_scene-master\examples\flutter_app\
It was successfully executed in CMD.
windows platform
Does the environment you run in have a LOCALAPPDATA environment setting?
(I think you can see that by writing set LOCALAPPDATA on the command line,
or maybe printing Process.environment["LOCALAPPDATA"] before doing the runSync.)
The includeParentEnvironment parameter to runSync should default to true, so if it's not there, maybe it's missing in the parent environment.
Does the environment you run in have a
LOCALAPPDATAenvironment setting? (I think you can see that by writingset LOCALAPPDATAon the command line, or maybe printingProcess.environment["LOCALAPPDATA"]before doing therunSync.)The
includeParentEnvironmentparameter torunSyncshould default totrue, so if it's not there, maybe it's missing in the parent environment.
This command works fine in PowerShell or Cmd, Why not in Process. runSync, which should be flawed, Or the logic of the windows platform。 I'm just learning about the framework, it's too complicated for me to debug the Sdk, hopefully I can optimize it in the new version