Error when building flutter app for Linux snap package using snapcraft - CMake step failing - flutter

This question has been asked here and (erroneously) closed as a duplicate with a link to an old CMAKE question. Probably the closing person did not read the question properly. This has nothing to do with plain CMake configuration, unless you want to configure the CMake use in snapcraft source code.
Error when building flutter app for Linux snap package using snapcraft
The fact is that running snapcraft fails. Running it with --debug gives you a root console of the snapcraft / multipass filesystem, whoami says root, but you only see the snap things around (for instance, not your home). Anyways, the error says
CMake Error: The current CMakeCache.txt directory /root/parts/xxxxx/build/build/linux/release/CMakeCache.txt is different than the directory
/home/zolal/flutterapps/xxxxx/build/linux/release where CMakeCache.txt was created. This may result in binaries being created in the wrong
place. If you are not sure, reedit the CMakeCache.txt
(naturally, you cannot reedit the CMAKECache.txt, because this is created by snapcraft)
It seems that the cmake build starts outside of the snapcraft / multipass VM, and than moves to the multipass VM resulting in CMake error. Because the original question was asked a while ago, obviously this still does not work. Did anyone solve this problem alredy?
Update, purged multipass and tried with lxd:
snapcraft --use-lxd
Launching a container.
Waiting for container to be ready
Waiting for network to be ready...
snap "snapd" has no updates available
The flutter plugin is currently in beta, its API may break. Use at your own risk.
snapd is not logged in, snap install commands will use sudo
snap "core18" has no updates available
Skipping pull flutter-extension (already ran)
Skipping pull geraspine-outcome-pc (already ran)
Skipping pull gnome-3-28-extension (already ran)
Skipping build flutter-extension (already ran)
Building geraspine-outcome-pc
flutter pub get
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
📎
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
Failed to run 'flutter pub get' for 'geraspine-outcome-pc': Exited with code 1.
Verify that the part is using the correct parameters and try again.
Run the same command again with --debug to shell into the environment if you wish to introspect this failure.
Naturally, the pubspec.yaml is there, but the files are obviously not transferred to the VM.

The solution is to execute following command inside your flutter project root folder (where the build, lib, snap, etc. folders are contained):
snapcraft clean <project-name>
This deletes the build cache inside "/root/parts/>project-name>" folder.
Should that not be enough, you can clean the whole snapcraft parts folder with
snapcraft clean
but this includes all dependencies. This means that all dependencies must be downloaded again the next time you compile your project.
Then delete the whole folder of your_part_name under parts folder
This doesn't work because the "parts" folder is inside "/root" dir and we cannot access or delete the stuff inside manually.
But it would be nice if we can change the parts folder e.g. into our /home dir. But I haven't found any possibilities yet !

If you got any error when building this, just run snapcraft build --debug
Then delete the whole folder of your_part_name under parts folder

Delete build directory and build again.
src github-issue

For me it was important to delete the build directory in my local directory also:
rm -rf build && snapcraft clean <project> && snapcraft

Related

TNS command not found after installing NativeScript

I updated NPM and Node before installing NativeScript, without errors I might add, but when I attempt to create a new project using tns create MyProjectName, I get the error tns command not found.
After much reading, I'm getting the feeling it has something to do with my PATH.
This is what is outputted in terminal during the NativeScript install regarding TNS:
sudo npm install -g nativescript --unsafe-perm
/Users/martingeldart/.npm-global/bin/tns -> /Users/martingeldart/.npm-global/lib/node_modules/nativescript/bin/tns
/Users/martingeldart/.npm-global/bin/nativescript -> /Users/martingeldart/.npm-global/lib/node_modules/nativescript/bin/tns
...
If I run echo $PATH, this is what outputs:
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/bin/lib/node_modules/nativescript/bin
Which looks really odd to me but I'm no command line expert by any means. In fact, I'm incredibly inexperienced with the whole command line system.
Why am I not able to access the tns command? What is going on with that PATH I echoed?
MacOSX
Between version of npm the location of the global package moved location in the OS. Since the installation has moved the terminal does not know where to find the command. The PATH variable is used to tell the terminal where all the command may be located. In this case this seems a standard.
Now the best way to access command from an installed package is to use npx which is included by default with the new installation of npm.
https://docs.npmjs.com/downloading-and-installing-packages-globally
npx tns
# In your case
npx tns create MyProjectName
There 2 other ways to resolve this.
Either your global package folder is not set up correctly.
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
Add the bin folder where nativescript was install to your path manually (usually in .bash_profile), open a new terminal.
I use nativescript for various project and I have a suggestion for package management. Usually I avoid installing global package because in case of multiple project there may be conflict between version if some project are updated and other not.
I usually create a folder with the version I am installing. Go to the folder, npm init and install locally the package.
mkdir nativescript-project-6-0
cd nativescript-project-6-0
npm init
npm i --save nativescript
Now I have a fix version to work with and can create other project with the same version even if I have other project with newer version of the tool or lib. Now in nativescript-project-6-0 I create my project.
npx tns create MyProjectName
This should create a folder nativescript-project-6-0/MyProjectName. All set and ready to go. Remember that is is always a good idea to use npx in this case since we want to use the local package.

`dot net restore` fails due to corrupted package

I just installed the LTS version of the .NET Core SDK (1.0.0-preview2-003156). I created a new project by using
dotnet new
However, this fails because
Failed to create prime the NuGet cache. restore failed with 1.
I followed the directions in this post to clear my local package cache and I am left with this package:
System.Security.Cryptography.Algorithms
The 4.2.0\ref sub-directory gives me this error when I try to open it:
The file or directory is corrupted and unreadable.
How do I go about clearing this package out or at least getting to the point where the package restore will work again?
I ended up having to run chkdsk against my machine. Because the package directory was on my C:\ drive, I had to reboot for it to run the disk repair. After the chkdsk completed, I was able to delete the package.

Snapcraft Placing Default Config Files

I am trying to build an application release by using Snapcraft.io, and I have almost all working.Snapcraft already compiles the source code, generates the .snap file, includes all the dependencies, and so on.However, I am stuck at how I can initialize some configuration files in the SNAP_USER_DATA folder after the first app install.I do not want to place the files in the default read-only path SNAP, as the default parameters should be modified by the user, also I need to generate some additional files, like server certificates.So I need to copy some files, and also run a script after the first install. Is this possible?
Thanks.
Because snaps are installed as root, it's impossible to do exactly as you ask at install time, as $SNAP_USER_DATA is user-specific, so it'll always be root's. However, you can do this at install-time using a system-wide directory, such as $SNAP_DATA, using the install hook:
$ snapcraft init
Created snap/snapcraft.yaml.
Edit the file to your liking or run `snapcraft` to get started
Create the hook. In our case we'll just create a new file in $SNAP_DATA, but you could do whatever you wanted.
$ mkdir -p snap/hooks
$ echo "touch \$SNAP_DATA/foo" >> snap/hooks/install
$ chmod a+x snap/hooks/install
Build the snap.
$ snapcraft
Preparing to pull my-part
Pulling my-part
Preparing to build my-part
Building my-part
Staging my-part
Priming my-part
Snapping 'my-snap-name' |
Snapped my-snap-name_0.1_amd64.snap
Install the snap. This will run the install hook.
$ sudo snap install my-snap-name_0.1_amd64.snap --devmode --dangerous
my-snap-name 0.1 installed
Notice a file was created in $SNAP_DATA.
$ ls /var/snap/my-snap-name/current
foo
The only way to get similar functionality for $SNAP_USER_DATA would be to wrap your real command in a script that creates the config. This command is then run by the user, which means you get the $SNAP_USER_DATA you intend. Of course, this isn't at install-time.

Install laravel ends up in wrong directory (composer with cygwin)

I am trying to install laravel with the use of cygwin, a command line tool for windows.
I use this line
composer create-project laravel/laravel=4.2.0 c/my_workspace/projectname --prefer-dist
which installs everything. But it does not end up in c:/my_workspace/projectname. Instead it ends up in cygwin64/c/my_workspace/projectname.
The next time I tried it it ended up in a different folder, also inside "cygwin64".
It doesn't matter what path I specify, the path will start in the cygwin64 folder for some reason. By the way, in cygwin there is a always a prefix for the paths called /cygdrive/. Is that what causes it to start from cygwin64?
I also tried instead to execute it from cmd by navigating to
cd c:/myworkspace
And then entering
composer create-project laravel/laravel=4.2.0 /projectname --prefer-dist
It says "Installling", and then "loading from cache" (?), then it says
failed to download laravel/laravel from dist: C:my_workspace/vendor/composer/5079c43b does not exist and could not be created
Then it tries to download from source. When cloning starts it fails:
Failed to clone git#github.com:laravel/laravel.git, git was not found
I managed to get it installed finally. I suppose there was something wrong with the way I wrote the filepath:
c/my_workspace/projectname
so it was created in the cygwin64 folder (for some reason). This time I navigated to the folder where I want the install:
cd c:/my_workspace/projectname
then install with:
composer create-project laravel/laravel=4.2.0 --prefer-dist
However, I got a mkdir() permission denied problem, which was solved by running cygwin as administrator.
Then I got another problem where you setup the laravel development server with
$ php artisan serve
It could not find the artisan file because it was located inside a "laravel" folder(!?), which I guess wasn't right, so I moved the laravel files back to my project folder and deleted the laravel folder. The laravel development server has started so I guess it works now.

Re-compiler QtEmbedded in OpenEmbedded without Examples

I have a touch panel computer running ARM9. I have successfully built a QtEmbedded SDK image under OpenEmbedded toolchain (I am newbie in this area) for ARM9. I'd like to re-build QtEmbedded images again with few examples that it comes (not all) with due to space limitation on NAND. How can I re-compile this. I have commented out examples in examples.pro but it seems it's building images from existing packages. I am using command: bitbake -b qt4-embedded-image
Please help.
Nimesh
You need to re-run the configure step of the bitbake to rebuild the Makefiles from the .pro files. You can do this by removing the configure stamp for this package. Just rm the do_configure stamp for this package and re-run the bitbake command you did above.