0

I'm trying to build a Dart project from inside a Vagrant VM. The project was actually created from my host machine using IntelliJ, but I would like that whoever uses the Vagrant VM is of course able to build the project (and in general do everything it's possible to do with a Dart project using the Dart tools), which is the main reason why I set up a Vagrant VM to develop.

So (as usual in a Vagrant environment) in my guest machine, the path /vagrant contains files which are the same (and synchronized) with the files where the Vagrantfile is located on my host machine.

My Dart project was created in the host machine under the folder dart-angular-client, which is at the same level as the Vagrantfile. I'm able to build the project from my host machine from inside dart-angular-client and from IntelliJ, but the idea was to be able to build the project from inside the Vagrant machine.

So, when I try to type pub build under /vagrant/dart-angular-client of my guest Vagrant VM, I obtain the following error

Could not find a file named "pubspec.yaml" in "/home/vagrant/.pub-cache/hosted/pub.dartlang.org/protobuf-0.5.3"

where /home/vagrant/ is basically the home directory of the guest Vagrant VM. I tried to install manually and globally a Dart package from inside the guest machine, and the package was indeed installed under /home/vagrant/.pub-cache, as one would expect, since (as far as I know) Dart packages that are installed/activated globally are put under that folder (even in my host machine).

How can I build my project from inside the Vagrant VM?


Edit

After doing pub get (as suggested by Günter Zöchbauer), when I run the command pub build now I obtain

vagrant@vagrant-ubuntu-trusty-64:/vagrant/dart-angular-client$ pub build
Loading source assets... 
Loading angular2/transform/codegen and dart_to_js_script_rewriter transformers... 
Loading angular2 transformers... (6.5s)Dumping native stack trace for thread c36
  [0x000000000091a708] dart::WeakTable::SetValue(dart::RawObject*, long)
  [0x000000000091a708] dart::WeakTable::SetValue(dart::RawObject*, long)
  [0x00000000008c3e20] dart::Scavenger::ProcessWeakReferences()
  [0x00000000008c464f] dart::Scavenger::Scavenge(bool)
  [0x00000000006f0298] dart::Heap::CollectNewSpaceGarbage(dart::Thread*, dart::Heap::ApiCallbacks, dart::Heap::GCReason)
  [0x00000000006f0cc8] dart::Heap::AllocateNew(long)
  [0x000000000078baf8] dart::Object::Allocate(long, long, dart::Heap::Space)
  [0x00000000007aadc3] dart::TypedData::New(long, long, dart::Heap::Space)
  [0x0000000000aeaf69] dart::BootstrapNatives::DN_TypedData_Uint8Array_new(_Dart_NativeArguments*)
  [0x00007f0cb907e579] Unknown symbol
  [0x00007f0cb737e97d] Unknown symbol
  [0x00007f0cab554524] Unknown symbol
  [0x00007f0cab5534ee] Unknown symbol
  [0x00007f0cab552588] Unknown symbol
  [0x00007f0cab551e6d] Unknown symbol
  [0x00007f0cb601dfba] Unknown symbol
  [0x00007f0cab551a53] Unknown symbol
  [0x00007f0cab54f4e9] Unknown symbol
  [0x00007f0cab50fde3] Unknown symbol
  [0x00007f0caeb01d4d] Unknown symbol
  [0x00007f0cb6c78cb0] Unknown symbol
  [0x00007f0cb52c198f] Unknown symbol
  [0x00007f0cb6c7a97e] Unknown symbol
  [0x00007f0cab56cf92] Unknown symbol
  [0x00007f0cab58165a] Unknown symbol
  [0x00007f0caeaee66d] Unknown symbol
  [0x00007f0cab581ff7] Unknown symbol
  [0x00007f0cab51bba1] Unknown symbol
  [0x00007f0caeb01d4d] Unknown symbol
  [0x00007f0cb6c78cb0] Unknown symbol
  [0x00007f0cb52c198f] Unknown symbol
  [0x00007f0cb6c7a97e] Unknown symbol
  [0x00007f0cab56cf92] Unknown symbol
  [0x00007f0cab58165a] Unknown symbol
  [0x00007f0caeaee66d] Unknown symbol
  [0x00007f0cab581ff7] Unknown symbol
  [0x00007f0cab52c77b] Unknown symbol
  [0x00007f0caeb01d4d] Unknown symbol
  [0x00007f0cb6c78cb0] Unknown symbol
  [0x00007f0cb52c198f] Unknown symbol
  [0x00007f0cb6c7a97e] Unknown symbol
  [0x00007f0cab56cf92] Unknown symbol
  [0x00007f0cab58165a] Unknown symbol
  [0x00007f0caeaee66d] Unknown symbol
  [0x00007f0cab5389f0] Unknown symbol
  [0x00007f0cb6c80a6d] Unknown symbol
  [0x00007f0cb6c8048c] Unknown symbol
  [0x00007f0cb30900bd] Unknown symbol
  [0x00007f0caeaebbe4] Unknown symbol
  [0x00007f0caeafbd71] Unknown symbol
  [0x00007f0caeafe6b8] Unknown symbol
  [0x00007f0cb6c80a6d] Unknown symbol
  [0x00007f0cb6c8048c] Unknown symbol
  [0x00007f0cb30900bd] Unknown symbol
  [0x00007f0cb6c915c2] Unknown symbol
  [0x00007f0cb6c80ae9] Unknown symbol
  [0x00007f0cb6c8048c] Unknown symbol
  [0x00007f0cb30900bd] Unknown symbol
  [0x00007f0cb6c915c2] Unknown symbol
  [0x00007f0cab582b12] Unknown symbol
  [0x00007f0cb651de80] Unknown symbol
  [0x00007f0caeaf2520] Unknown symbol
  [0x00007f0cab58756e] Unknown symbol
  [0x00007f0cb907e836] Unknown symbol
  [0x000000000064e2f0] dart::DartEntry::InvokeFunction(dart::Function const&, dart::Array const&, dart::Array const&)
  [0x00000000006521bd] dart::DartLibraryCalls::HandleMessage(dart::Object const&, dart::Instance const&)
  [0x000000000074f4e8] dart::IsolateMessageHandler::HandleMessage(dart::Message*)
  [0x000000000077124a] dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)
  [0x00000000007715e1] dart::MessageHandlerTask::Run()
-- End of DumpStackTrace

which seems a little bit more severe. I'm not sure what caused this problem (pub, Vagrant, etc), but that seems C++ code. This looks like some stack corruption... This happened after having built the project from the host machine, but (as far as I've understood) the build (if it exists) is replaced whenever we try to rebuild the Dart project.

Edit 2

I retried to reload and provision the virtual machine again, and then I ssh inside it, and I tried to build the Dart project again, and this was similarly the result:

Loading source assets... 
Loading angular2/transform/codegen and dart_to_js_script_rewriter transformers... 
Loading angular2 transformers... (7.3s)runtime/vm/scavenger.cc: 399: error: Out of memory.
Dumping native stack trace for thread 9f9
(7.4s)  [0x000000000087b7ee] dart::Profiler::DumpStackTrace()
  [0x000000000087b7ee] dart::Profiler::DumpStackTrace()
  [0x00000000005c8f5d] dart::DynamicAssertionHelper::Fail(char const*, ...)
  [0x00000000008c353d] dart::Scavenger::Prologue(dart::Isolate*, bool)
  [0x00000000008c43e6] dart::Scavenger::Scavenge(bool)
  [0x00000000006f0298] dart::Heap::CollectNewSpaceGarbage(dart::Thread*, dart::Heap::ApiCallbacks, dart::Heap::GCReason)
  [0x00000000006f0cc8] dart::Heap::AllocateNew(long)
  [0x000000000078baf8] dart::Object::Allocate(long, long, dart::Heap::Space)
  [0x000000000078bca8] Unknown symbol
  [0x00000000006520cf] dart::DartLibraryCalls::HandleMessage(dart::Object const&, dart::Instance const&)
  [0x000000000074f4e8] dart::IsolateMessageHandler::HandleMessage(dart::Message*)
  [0x000000000077124a] dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)
  [0x00000000007715e1] dart::MessageHandlerTask::Run()
-- End of DumpStackTrace
Aborted (core dumped)

Edit 3

Not even having destroyed and vagrant up the VM, it seems to have changed something, since I obtained:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/dart-angular-client$ pub build
Loading source assets... 
Loading angular2/transform/codegen and dart_to_js_script_rewriter transformers... 
Loading angular2 transformers... (11.8s)runtime/vm/scavenger.cc: 399: error: Out of memory.
Dumping native stack trace for thread 2646
  [0x000000000087b7ee] dart::Profiler::DumpStackTrace()
(17.0s)  [0x000000000087b7ee] dart::Profiler::DumpStackTrace()
  [0x00000000005c8f5d] dart::DynamicAssertionHelper::Fail(char const*, ...)
  [0x00000000008c353d] dart::Scavenger::Prologue(dart::Isolate*, bool)
  [0x00000000008c43e6] dart::Scavenger::Scavenge(bool)
  [0x00000000006f0298] dart::Heap::CollectNewSpaceGarbage(dart::Thread*, dart::Heap::ApiCallbacks, dart::Heap::GCReason)
  [0x00000000006f09b9] dart::Heap::AllocateOld(long, dart::HeapPage::PageType)
(17.6s)  [0x000000000078ba67] dart::Object::Allocate(long, long, dart::Heap::Space)
  [0x000000000078bca8] Unknown symbol
  [0x00000000007d2c2b] dart::HashMap<dart::UnorderedHashTable<dart::CompressedTokenTraits, 1l> >::InsertOrGetValue(dart::Object const&, dart::Object const&) const
  [0x00000000007d31e8] dart::CompressedTokenStreamData::AddToken(dart::Scanner::TokenDescriptor const&)
Killed
nbro
  • 15,395
  • 32
  • 113
  • 196
  • Sounds like you are missing a `pub get` command or `/home/vagrant/.pub-cache` is somehow corrupt. Are you sure (if you actually run `pub get`) that the command was completed before `pub build` is run? Is this `.pub-cache` directory recreated every time before you build in vagrant, or is a previous version kept? (I don't know Vagrant) – Günter Zöchbauer Feb 13 '17 at 17:05
  • @GünterZöchbauer Oh, since I'm very new to Dart (I still need to learn the language), I didn't know I had to do `pub get` manually, I thought `pub build` would have performed that automatically in case the dependencies were not resolved.. – nbro Feb 13 '17 at 17:09
  • No. `pub get` needs to be called explicitly. You need that already during development - for example in WebStorm to get auto-completion for imported code. – Günter Zöchbauer Feb 13 '17 at 17:13
  • @GünterZöchbauer Ok, thanks. See my edit, please. – nbro Feb 13 '17 at 17:18
  • Are you using the same Dart version in Vagrant as on your host machine? What version is it? – Günter Zöchbauer Feb 13 '17 at 17:25
  • Yes, the `build` directory is purged as first step of a `pub build` run. – Günter Zöchbauer Feb 13 '17 at 17:26
  • @GünterZöchbauer This is what I obtain when I type `dart --version` on my host machine: `Dart VM version: 1.21.1 (Fri Jan 13 01:40:43 2017) on "macos_x64"` and this is what I obtain when I'm inside the guest VM: `Dart VM version: 1.21.1 (Fri Jan 13 09:44:01 2017) on "linux_x64"`. – nbro Feb 13 '17 at 17:29
  • "Out of memory" seems pretty clear ;-) – Günter Zöchbauer Feb 13 '17 at 17:34
  • @GünterZöchbauer Yes, I will try to destroy and _up_ the Vagrant VM again and see if this happens again... – nbro Feb 13 '17 at 17:35
  • 1
    http://stackoverflow.com/questions/12308149/how-do-i-increase-the-ram-and-set-up-host-only-networking-in-vagrant might help (just did a search and posted the first link) – Günter Zöchbauer Feb 13 '17 at 17:37

1 Answers1

0
Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • 1
    Yes, essentially combining these two solutions in order solved both respectively the first and the second problem. – nbro Feb 13 '17 at 18:05