While running the Get Started guide for Dart and using WebStorm as per the docs, Dartium window shows "502 Bad Gateway" when trying to run index.html for the first time.
When inspecting the IDE, the Pub Serve console shows an error while trying to run % .../pub serve web --port=<port>:
No pubspec.lock file found, please run "pub get" first
I went into my get_started project folder on the terminal and ran the same pub serve command and got the same error.
I am running WebStorm 2016.3.2 and Dart sdk 1.21.0 on Linux x64.
What is the proper procedure to follow here?
WebStorm IDE has been known to have this bug where it fails to run pub get on a project which will cause failures when trying to run the project.
To verify if this is occurring, go into the IDE and check for a Pub Serve warnings message at the bottom of the window. If you see the errors outlined in the OP, then this solution should work.
The problem without running pub get is that the project dependencies have not been resolved and thus the server cannot start.
In the IDE, check the project root for a file pubspec.yaml. Right click the file and select Pub: Get Dependencies. Check the Messages window to follow for the progress. If it finishes ok, the problem should be corrected.
Alternatively, you could run pub get manually from command line as you would do without an IDE.
[Update] The Dart team has updated the documentation to guide users on this issue: https://kw-webdev-dartlang-1.firebaseapp.com/guides/get-started (Pull request #329)
Related
I just installed Exercism and would like to test if I managed to complete the hello-world assignment.
I changed the hello_world.dart file in the lib folder to print the solution, but now I am struggling with running the test file.
In the guide it says to simply run
$ pub run test
Is the $-sign meant to mean something to me? Cause all I am getting is: "'$' is not recognized as an internal or external command,operable program or batch file." I have the same issue with running "pub get" or "pub run test". (What does pub mean?)
To summarize, I ran:
exercism configure "my token"
exercism download --exercise=hello-world --track=dart
cd C:\Users\Martin\exercism\dart\hello-world
I changed the file in C:\Users\Martin\Exercism\dart\hello-world\lib
And then I tried
$ pub run test
pub run test
pub get
And none of these seem to do anything. So, I don't know how to test my file.
I do have flutter installed and run is fine with Android Studio, if that is relevant. It seems to me that I can choose to write the solution in both notepad++ or Android Studio.
Thanks for any help
pub is package manager for dart programming language, just like npm for javascript. Since you've installed it on WINDOWS i'm guessing you used choco - package manager to install the dart-sdk. https://dart.dev/get-dart.
Once installed make sure you've set dart-sdk the path in Environment variable.
Can anyone tell me why my app is not installing at all and ending with the error message
Observatory connection never became ready.
the app was working perfectly fine until yesterday .
I have changed the channel to master yesterday in the command prompt and from then on the app never runs.
I even switched back to channel alpha but still no use.
I have attached a screenshot of the command prompt where the installation was stuck forever.
I am not so sure if I need to reinstall the flutter. I am worried if I uninstall the flutter now it may not configure properly and I might break it forever.
Please can someone tell me what exactly might have gone wrong.
Many Thanks,
Mahi
Instead of reinstall try with following: (Mac)
Set Path Variable: via following terminal command
export PATH=~/flutter/bin:$PATH;
that is bin folder path of flutter.
export PATH=[PATH_TO_FLUTTER_GIT_FOLDER]/bin:$PATH
https://flutter.io/setup-macos/#update-your-path
If above not worked. Check with the Dart version
dart --version
Install the latest dart version:
brew install dart --devel
Hope this helps others.
For Mac
open terminal
$ echo $PATH
it will show like this
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:
it means you need to add flutter in to path
Open Finder presss command + shift + G
Put /etc/paths in dialog and press GO
Copy the file "paths" and paste it on desktop
Then open the pasted "paths" file from desktop
and add following line into end of the file "/flutter/bin"
Then copy that file and again paste it on /etc/paths
same like step no 2
it will ask you to replace or not
press replace
Now if you hit $ echo $PATH on terminal it will show
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/swagat/development/flutter/bin
Now your $flutter doctor will work perfectly
The solution is from Google Groups #Flutter-Dev
Thank you very much for your reply #Michael Thomsen.
I've tried what you have suggested and the details are as follows:
When I used flutter run -v command the command prompt output is as follows:
It was stuck for a while at waiting for port connection if I am not wrong.
So I've used AndroidStudio, File>Open and selected android/ folder to run the app then the gradle was showing an error:
Error:Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (25.2.0) and test app (25.4.0) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
I modified the build.gradle(Module:app) to show the correct version of 25.2.0 which was previously showing 25.4.0.
dependencies {
androidTestCompile 'com.android.support:support-annotations:25.2.0'
}
I just saved the changes inside android studio and the gradle sync completed without any errors.
Now I can run the app from inside Android Studio and also from IntelliJ IDE.
Thanks very much Michael this solved my problem.
Reinstalling flutter would be my starting point. If this problem persists, please post the output of $>flutter doctor and a description of what exactly leads to this error.
I am using WebStorm 2017.2
(172.3317.70, built on July 14, 2017) And the latest stable release of Dart (1.24.2) and I am receiving errors for almost of my imports (except dart core packages eg. dart:async):
error: Target of URI doesn't exist: 'package:charted/charted.dart'.
I have run pub get within WebStorm, and tried pub upgrade and pub get via command line as well. When this did not work I also tried pub cache repair with no prevail.
The errors seem to only affect Webstorm, the application builds with no problems and all packages work fine when using pub build in terminal. This problem only arose when I upgraded dart and Webstorm.
When I make changes to the project the analysis server has to catch up, and will often change its mind about whether or not the URI error persists.
Since I have made no changes to my pubspec.yaml files or the project itself, and the project still builds fine in cmd line, is this a potential bug?
[UPDATE]: I reverted to the old version of dart sdk, and immediately ran pub get and everything worked. I then reverted back to the latest version making sure to run pub get right away, and it seems to be cooperating.
[UPDATE 2]: Issue is definitely recurring. Very hit or miss, currently still have the errors.
When I try to import a package with the syntax import 'package:markdown/markdown.dart';, I get no error in Dart Editor but when I run the dart application, the debugger shows me the message:
An error occurred loading file: package:markdown/markdown.dart
Failed to load resource
chrome-extension://gfjabgeipkcfopofkhjimepepnomcidk/dart/packages/markdown/markdown.dart
But when I write the whole path (import "../../packages/markdown/markdown.dart";) everything works fine. I cannot understand why the syntax package: doesn't work in my code though it works in Dart Editor's own examples.
You can see the Chrome app architecture below (I'm loading a package from translator.dart):
You should have the package added as a dependency in pubspec.yaml (which I assume you do).
Also try running following:
delete packages folder
delete pubspec.lock
run pub get to fetch the
dependencies again.
I think in your md_to_html folder you need a link to the 'packages' directory for the shortform to work. I seem to remember this happening when the workspace is built but I'm not sure now which command triggers it, have a look at the current pub docs.
I have a project that uses Dart and the web_ui package. I just upgraded Dart to libv2, specifically:
Dart Editor version 0.3.1_r17594
Dart SDK version 0.3.1.3_r17594
I just updated web_ui to 0.3.0+2.
Now, I'm getting these errors:
Cannot find referenced source: package:web_ui/web_ui.dart
no such type "WebComponent"
"ChatWindowComponent" has no method named "dispatch"
When I run my build.dart, it completes successfully, but it doesn't create an out directory. Nor does it give any error messages.
What's going on? Why can't it find package:web_ui/web_ui.dart? I can clearly see that pub has set stuff up correctly.
It's a known issue. See http://code.google.com/p/dart/issues/detail?id=7822. The issue was closed today. I tried out a continuous build of Dart Editor, but that lead to different errors--I'll save that for another question.
When I run my build.dart, it completes successfully, but it doesn't create an out directory. Nor does it give any error messages.
I run the editor with 'automatically run pub' disabled. Creating a new web ui projects yields a few errors, after installing pub the errors are gone, but the timestamps of the files are to old now.
I changed the file that was to build and the out directory appeared immediately.