fvm
fvm copied to clipboard
[BUG] The method '[]' was called on null on 'dependencies'
Before creating a bug report please make check the following
- [ ] You have read our FAQ
- [x] If you have used flutter. Please install correctly, run
pub cache repair
. Close the terminal and try again. - [-] If you are on Windows. Make sure you are running the terminal as
administrator
or withdeveloper
permissions. - [x] Run
fvm doctor
if possible and add the output to the issue.
Describe the bug A clear and concise description of what the bug is.
Several commands, for example flutter use
in a flutter project directory caused.
I checked several times I'm in a directory that contains the pubspec.yaml
Unhandled exception:
NoSuchMethodError: The method '[]' was called on null.
Receiver: null
Tried calling: []("dependencies")
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
#1 ProjectService.isFlutterProject (package:fvm/src/services/project_service.dart:107:33)
<asynchronous suspension>
#2 ProjectService.getByDirectory (package:fvm/src/services/project_service.dart:24:25)
<asynchronous suspension>
#3 ProjectService.findAncestor (package:fvm/src/services/project_service.dart:125:21)
<asynchronous suspension>
#4 ProjectService.findAncestor (package:fvm/src/services/project_service.dart:137:12)
<asynchronous suspension>
#5 ProjectService.updateLink (package:fvm/src/services/project_service.dart:36:21)
<asynchronous suspension>
#6 ensureCacheWorkflow (package:fvm/src/workflows/ensure_cache.workflow.dart:28:7)
<asynchronous suspension>
#7 useVersionWorkflow (package:fvm/src/workflows/use_version.workflow.dart:26:3)
<asynchronous suspension>
#8 UseCommand.run (package:fvm/src/commands/use_command.dart:88:5)
<asynchronous suspension>
#9 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#10 FvmCommandRunner.run (package:fvm/src/runner.dart:72:24)
<asynchronous suspension>
#11 main (file:///home/user/.pub-cache/hosted/pub.dartlang.org/fvm-2.1.0/bin/main.dart:6:8)
<asynchronous suspension>
To Reproduce Steps to reproduce the behavior:
- Go to terminal..
- Run
fvm use stable
... - Check...
- See error
Expected behavior A clear and concise description of what you expected to happen.
Logs
Please provide the verbose logs by running --verbose
after the command.
Desktop (please complete the following information):
- OS: [e.g. iOS]
- FVM Version [e.g. 22]
- If Windows: Which Powershell are you using?
Additional context Add any other context about the problem here.
I tried older versions because I haven't worked with Dart since quite some time and just updated everything before starting a new project.
I tried several versions without success until I got back as far as 2.0.0.
With this version fvm use stable
succeeded.
After that it also succeeded with every newer version.
So you can just close this issue. I just thought it might be helpful for others looking for the error message.
I still got the error message in directories without pubspec.yaml
for example for fvm global stable
.
I first hat to execute fvm global stable
in a directory with a pubspec.yaml
, then it also worked in directories that do not contain a pubspec.yaml
.
Probably a real bug then.
It looks like this somehow came from the directory I assumed was not a flutter project actually contained an empty pubspec.yaml
. Perhaps this got created in the process of tracking down the issue.
Otherwise it would be hard to explain how downgrading and upgrading could solve this.
A pubspec.yaml without dependencies
(even though unlikely in Flutter) shouldn't cause this error anyway.
@zoechi will leave this open.. will check for error handling the dependencies.. There is a bit of a clean up scheduled to minimize the footprint of the project API, so I will leave this open for now.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@zoechi I am doing some clean up on the issues. It seems like its behaving correctly. The way FVM determines if its a flutter project, its by find Flutter in the dependencies on pubspec. The error should give you a way to force it. Will close this issue, please feel free to create a new one if needed