From Linux, I'm using Meson (0.44.0) within Gnome Builder (3.26.4) for a console program that will use Gee and GXml. My intent is to write this in Genie.
When I use Meson within Gnome Builder it fails but the same succeeds when invoked from the command line using valac (0.38.8) as follows:
valac --pkg=gtk+-3.0 --pkg=gee-0.8 --pkg=gxml-0.16 main.gs
There is no error from the above. I've tried setting up meson.build with gee and gxml as dependency and alternatively as vala_args. Same error.
Checking pkg-config, I get the following:
$ pkg-config --libs gxml-0.16
-L/usr/local/lib64 -lgxml-0.16 -lgio-2.0 -lxml2 -lgee-0.8 -lgobject-2.0 -lglib-2.0
$ pkg-config --libs gee-0.8
-lgee-0.8 -lgobject-2.0 -lglib-2.0
$ pkg-config --libs gee-1.0
-lgee -lgobject-2.0 -lglib-2.0
Perhaps I'm doing something wrong. Here is the local meson.build file followed by the top level meson.build and the error:
example_sources = [
'main.gs'
]
example_deps = [
dependency('gio-2.0', version: '>= 2.50'),
dependency('gtk+-3.0', version: '>= 3.22'),
dependency('glib-2.0', version: '>= 2.50')
]
gnome = import('gnome')
example_sources += gnome.compile_resources(
'example-resources',
'example.gresource.xml',
c_name: 'example'
)
executable(
'example',
example_sources,
vala_args: '--target-glib=2.50 --pkg=gee-0.8 --pkg=gxml-0.16',
dependencies: example_deps,
install: true
)
with top-level meson.build:
project(
'example',
['c', 'vala'],
version: '0.1.0',
meson_version: '>= 0.40.0',
)
subdir('src')
And the error is:
uses Gee
error: The namespace name 'Gee' could not be found
I'm invoking the build from within Gnome-Builder. Can someone help me understand what is happening? I've tried to find why valac succeeds and meson fails in the documentation but cannot find a solution.
Gee and GXml should be dependencies, just like GIO, GLib and GTK+. So you should try:
example_deps = [
dependency('gio-2.0', version: '>= 2.50'),
dependency('gtk+-3.0', version: '>= 3.22'),
dependency('glib-2.0', version: '>= 2.50'),
dependency('gobject-2.0'),
dependency('gee-0.8'),
dependency('gxml-0.16'),
]
Usually you won't need to go beyond that. This makes the --pkg options in the vala_flags unnecessary. Meson does that for you. The way Meson works is it uses valac to produce C code then in a separate stage uses a C compiler to produce the binary. By using --pkg you are only telling valac which VAPI file to use, but not notifying the C compiler which pkg-config package to use for the C library.
Also notice I've added gobject-2.0 as a dependency. If I remember correctly GNOME Builder misses that and it does affect the build.
The error message, error: The namespace name 'Gee' could not be found, is troubling. This is an error from the Vala compiler and I would have thought that the compiler would be able to find the VAPI file using the vala_args method you've tried. Maybe you have Gee built from source and not installed system wide?
Meson does allow another VAPI search directory to be added:
add_project_arguments(['--vapidir',
join_paths(meson.current_source_dir(), 'vapi')
],
language: 'vala'
)
There are more details on the Vala page of the Meson Build documentation.
Genie support was added to Meson with version 0.42. So meson_version: should be >= 0.42.0.
If there are still problems then here is an MCVE using Genie, Gee and Meson. This should be compiled from the command line. Save the following Genie program as genie-gee.gs:
[indent=2]
uses Gee
init
var my_list = new ArrayList of string()
my_list.add( "one" )
my_list.add( "two" )
for item in my_list
print( item )
Then save the following Meson file as meson.build:
project('minimal-genie-gee-example',
'vala', 'c'
)
genie_gee_deps = [
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('gee-0.8'),
]
executable('genie-gee',
'genie-gee.gs',
dependencies: genie_gee_deps
)
From the command line use Meson to set up the build directory:
meson setup builddir
This should show the dependencies have been found, for example:
Native dependency gee-0.8 found: YES 0.18.0
Then use Ninja build to build the project:
ninja -C builddir
For anyone using Fedora ninja is ninja-build.
Any problems with Meson setting up the build directory are logged to builddir/meson-logs/meson-log.txt.
If this works, but it fails in GNOME Builder, then my only other thought is that GNOME Builder has been installed using Flatpak. The sandboxed environment of Flatpak may be affecting the access to dependencies.
Update: Following the discussion in the comments it appears the runtime used by GNOME Builder was the problem. Builder has a great feature of being able to select the Flatpak runtime used to build your software. If you are following the 'traditional' way of developing by installing libraries and header files on your workstation then make sure Host Operating System is selected instead of a Flatpak runtime. It would appear the GNOME Flatpak runtime does not include libgee.
Update2: When writing a Flatpak builder manifest and a dependency is not in the Flatpak runtime/SDK then add the dependency as another module in the Flatpak builder manifest. This allows GNOME Builder to use Flatpak to build the software with the Flatpak runtime. An example manifest is given in AsymLabs answer.
Well after some exploration and AlThomas' advice above, here is what I discovered. OpenSUSE Tumbleweed provides four (or more) ways to install Gnome-Builder. These are:
1) Via Gnome Software Center. This installs org.gnome.Builder/stable in a sand boxed environment using Flatpak.
2) Via Flathub.org using Flatpak from the command line. This installs org.gnome.Builder/master (nightly) in a sand-boxed environment.
3) Via the package manager zypper and the command line. This installs a stable Gnome-Builder and related libraries system-wide.
4) Via Yast2. This provides the same as Zypper.
All three installations (same version 3.26.4 - different branches/tags - stable, master, nightly - two sand-boxed and one system wide) can be installed side by side and used as needed. During initial setup and testing, all variants yielded the same outcome - when using Gee and GXml only a Default build would work (the Flatpak Manifest would not build) but this has been resolved (it now appears that this is purely a Flatpak issue was a conflict between Flatpak and Fuse).
The Default build enables the Host runtime system. To set the Default build environment, upon opening a project within Gnome-Builder, choose Build Preferences from the upper left popover menu and select Default.
The drawback to a Default configuration is that it is not possible to Export Bundle, but local builds can utilize system-wide features.
So what is a Flatpak Manifest and why is it so important? It is the top level JSON file that contains project information. The Flatpak Manifest, in this case org.gnome.Example.json, pulls together all the features of the project so that it may be packaged for distribution. This includes the runtime, sdk, system connectivity to X11, IPC, Wayland, DBus, etc, the build system (Meson by default), cleanup directives, configuration and build options, submodule details (dependencies) and many other features. One Flatpak package can be installed in just about any Linux distribution, whether Debian, Ubuntu, Red Hat, OpenSuse or their derivatives, for example, and is sand-boxed for security and portability purposes. It will be, in future, fully cross-platform.
For instruction and testing, there are Flatpak Manifest examples to illustrate how they work. There are ways to alter the sand-box permissions using build finish directives. Flatpak documentation is excellent.
Within Gnome Builder when you first create a project, choose Vala + Gnome Application and a valid Flatpak Manifest will be installed. By default this is intended for a GUI rather than command line application; nonetheless it generates a default Flatpak Manifest that can be used as a template (Gnome Builder will allow multiple manifests - just select the build required). The following is the resulting improved Flatpak Manifest that will build submodules for both Gee and GXml (this has been tested within Gnome Builder and works):
{
"app-id": "org.gnome.Example",
"runtime": "org.gnome.Platform",
"runtime-version": "master",
"sdk": "org.gnome.Sdk",
"command": "example",
"finish-args": [
"--share=network",
"--share=ipc",
"--socket=x11",
"--socket=wayland",
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf"
],
"build-options": {
"cflags": "-O2 -g",
"cxxflags": "-O2 -g",
"env": {
"V": "1"
}
},
"cleanup": [
"/bin",
"/include",
"/lib",
"/lib/pkgconfig",
"/share",
"/share/vala",
"*.la",
"*.a"
],
"modules": [
{
"name": "libgee",
"buildsystem": "meson",
"config-opts": [
"--libdir=lib"
],
"builddir": true,
"sources": [
{
"type": "git",
"tag": "meson",
"url": "https://github.com/GNOME/libgee.git"
}
]
},
{
"name": "libgxml",
"buildsystem": "meson",
"config-opts": [
"--libdir=lib"
],
"builddir": true,
"sources": [
{
"type": "git",
"branch": "master",
"url": "https://gitlab.gnome.org/GNOME/gxml.git"
}
]
},
{
"name": "example",
"buildsystem": "meson",
"config-opts": [
"--libdir=lib"
],
"builddir": true,
"sources": [
{
"type": "git",
"url": "file:///home/<user>/Projects/example"
}
]
}
]
}
Hat's off to the folks who are developing this package. Combining Flatpak, Meson, Gtk3/4/5/.., Vala, Genie (and soon the Vulkan 3D graphics engine) and beautifully minimalistic UI guidlines/standards in one lightweight development platform is something magical, akin to a modern day alchemy.
As an aside, I tried using Gtk3 with a number of languages, including C/C++, D, Haskell and Python but none of these alternatives could produce stand-alone binaries that were as compact, efficient and fun to write as Vala and Genie. These are greatly underrated languages.
Concluding, anyone who needs a good starting point when trying to understand these technologies and how Gnome-Builder is bringing them together can read AlThomas' post above and this one, along with the comments. It may save a lot of time.
Maybe I don't understand SemVer syntax or maybe I don't understand bower (I have version 1.4.1), but I have an app whose bower.json is:
{
"name": "MyApp",
"description": "My AngularJS Project....",
"version": "0.0.0",
"homepage": "https://github.com/angular/angular-seed",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.3.x",
"angular-route": "1.3.x",
"angular-loader": "1.3.x",
"angular-mocks": "~1.3.x",
"angular-ui-grid": "~3.0.0-rc.20",
"angular-spinkit": "~0.3.3",
"angular-bootstrap": "0.13.0",
"bootstrap": "3.3.4",
"angular-animate": "~1.3.x",
"file-saver.js": "~1.20150507.2"
},
"resolutions": {
}
}**
When I do a 'bower update', it is “unable to find a suitable version for angular”, but I don't understand why not. Here's the output (#1 seems to be the problem):
Unable to find a suitable version for angular, please choose one:
1) angular#>=1.2.16 <=1.3.x which resolved to 1.2.28 and is required by angular-ui-grid#3.0.0-rc.22
2) angular#1.3.16 which resolved to 1.3.16 and is required by angular-animate#1.3.16, angular-loader#1.3.16, angular-mocks#1.3.16, angular-route#1.3.16
3) angular#1.3.x which resolved to 1.3.16 and is required by MyApp
4) angular#>=1.3.0 which resolved to 1.3.16 and is required by angular-bootstrap#0.13.0
5) angular#* which resolved to 1.3.16 and is required by angular-spinkit#0.3.3
So my reading of that output is that all packages would be happy with version 1.3.16 of angular, except for angular-ui-grid (“resolved to 1.2.28”) But why? Isn't 1.3.16 >=1.2.16 <=1.3.x ? And so isn't version 1.3.16 of Angular a suitable version? isn't it the ONLY suitable version? or maybe I'm misunderstanding what bower is trying to tell me.
I do understand that I can select one of the choices and even add a '!' to persist my choice, but I don't understand why a choice is needed.
Thanks
c0bra - thanks for setting up that plunker - it helped me to easily verify what I believe I finally (after lots of digging) determined is the problem:
there seems to be a bug in older versions of semver.js - I traced down, down, down into the code and the <=1.3.x gets morphed into <=1.3.0-0, and that means that 1.3.16 fails that test.
But that bug has been fixed in the NPM-delivered semver module - I was able to use your plunker to demonstrate to myself that 1.3.16 passes the test with 'latest' semver code, just as you set it up, but fails when I switch to older versions of semver (e.g. "^2.3.0", which seems to be what the bower package requires in its packages.json).
But even the latest bower on github seems to have that ^2.3.0 dependency for semver. So I'll see if I can submit a request to whoever maintains bower to get that upgraded. But I do not see much activity on bower/github of late.
In the meantime, I guess I'm stuck with being forced to answer the question above, since I'm using NPM to get bower, I don't think I can easily override it's semver dependency.
I get the following error:
Message:
Unable to find suitable version for underscore
Details:
code: ECONFLICT
picks: [object Object],[object Object],[object Object]
With the following bower file, this error I have never come across before. I cannot use the interactive shell, as this gets deployed to continuous integration. We also prefer to use Github repo links (don't ask me why) over bower packages.
{
"name": "Nightbird",
"version": "0.0.1",
"main": "src/css/style.scss",
"dependencies": {
"backbone": "git#github.com:jashkenas/backbone.git#1.1.2",
"underscore": "git#github.com:jashkenas/underscore.git#1.6.0",
"aisis-bootstrap-theme": "git#github.com:AdamKyle/Aisis-Bootstrap-Theme.git#0.5.0",
"selectize.js": "git#github.com:brianreavis/selectize.js.git#0.8",
"underscore.string": "git#github.com:epeli/underscore.string.git#v2.3.2",
"jquery-bootpag": "git#github.com:botmonster/jquery-bootpag.git#1.0.5",
"underscore.inflection": "git#github.com:jeremyruppel/underscore.inflection.git",
"moment": "git#github.com:moment/moment.git",
"bootstrap-markdown": "git#github.com:toopay/bootstrap-markdown.git#2.5.0",
"markdown-js": "git#github.com:evilstreak/markdown-js.git#v0.5.0",
"to-markdown": "git#github.com:domchristie/to-markdown.git#v0.0.2",
"font-awesome": "git#github.com:FortAwesome/Font-Awesome.git#4.2.0",
"react-bower": "git#github.com:reactjs/react-bower.git#0.11.1",
"showdown": "git#github.com:coreyti/showdown.git#0.3.1",
"pure": "git#github.com:yahoo/pure.git#0.5.0"
}
}
Any idea whats going on? Is this a bug? or just a developer being dumb?
You have a conflict between 3 different versions of underscore.
The reason for this is that underscore is required by 3 of your dependencies: Nightbird, backbone and underscore.inflection.
Using the latest version of Bower you can see the following information:
Unable to find a suitable version for underscore, please choose one:
1) underscore#1.6.0 which resolved to 1.6.0 and is required by Nightbird
2) underscore#>=1.5.0 which resolved to 1.6.0 and is required by backbone#1.1.2
3) underscore#~1.7.0 which resolved to 1.7.0 and is required by underscore.inflection#1.2.0
You can force bower to use a specific version in case of resolution by adding the following to your bower.json. In this example it will force using 1.6.0:
"resolutions": {
"underscore": "1.6.0"
}
I have recently started to learn ZendFramework2 and am at the part where I need to run php composer.phar install to initialize the skeleton application. I've already successfully executed the following instruction:
git clone git://github.com/zendframework/ZendSkeletonApplication.git
I know I have good outbound connectivity. My problem occurs when I get to the part, where I need to install the composer. I get the following output:
rt_zapzap#zingzing1:/var/www/ZendApp$ composer install
Loading composer repositories with package information
Installing dependencies
- Installing zendframework/zendframework (2.2.0rc3)
Downloading: connection...
[Composer\Downloader\TransportException]
The "https://api.github.com/repos/zendframework/zf2/zipball/release-2.2.0rc3" file could not be downloaded (HTTP/1.0 400 Bad Request)
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom- installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]
For reference my composer.json looks like
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": ">2.2.0rc1"
}
}
Any idea where I might look to correct this issue?
when you use the zend skeleton to start your new project and composer to install packages it recommends this:
"doctrine/common": "Doctrine\\Common >=2.1 for annotation features",
"ext-intl": "ext/intl for i18n features",
"pecl-weakref": "Implementation of weak references for Zend\\Stdlib\\CallbackHandler",
"zendframework/zendpdf": "ZendPdf for creating PDF representations of barcodes",
"zendframework/zendservice-recaptcha": "ZendService\\ReCaptcha for rendering ReCaptchas in Zend\\Captcha and/or Zend\\Form"
I could install the zendpdf, zendservice-recaptcha and doctine/common package but not the PECL ones.
I think it's a little sad that zf2 suggest the packages, but leaves users alone with, how to properly configure the composer.json.
I heard composer could also get PECL packages, but couldn't find any documentation on it.
How do I install them?
To install the suggested packages, modify composer.json to include them.
"repositories": [
{
"type": "composer",
"url": "http://packages.zendframework.com/"
}
],
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.*",
"doctrine/common": "dev-master",
"zendframework/zendpdf": "2.*",
"zendframework/zendservice-recaptcha": "2.*"
}
Then run
php composer.phar update
Note: that composer installs doctrine/common by using
git clone http://github.com/doctrine/common
On Windows git needs to be in your PATH environment variable.
Regarding ext/intl, this extension is bundled with PHP as of PHP version 5.3.0. and can be found in the ext/ folder of your php installation.[1]
To enable, uncomment (remove the semi-colon before the directive) it in php.ini
extension=php_intl.dll
Regarding pecl-weakref, this is also a PHP extension however this is not bundled with php and needs to be installed. More information on how to do that can be found at http://php.net/manual/en/install.pecl.php
A DLL for this PECL extension is currently unavailable. See also the
building on Windows section. [4]
[1] http://php.net/manual/en/intl.requirements.php
[2] http://php.net/manual/en/weakref.installation.php
[3] http://php.net/manual/en/install.pecl.intro.php
[4] http://php.net/manual/en/install.pecl.windows.php