ES6: Tests pass in browser, fail with phantomJS, "Can't find variable: Reflect" - ecmascript-6

I am doing an ES6 rewrite for a js library.
class VerbalExpression extends RegExp {
// snipped for brevity
}
/**
* Alias for the constructor
* #return {VerbalExpression} new instance of VerbalExpression
*/
function instantiate() {
return new VerbalExpression();
}
// UMD (Universal Module Definition)
// https://github.com/umdjs/umd
if (typeof module !== 'undefined' && module.exports) { // CommonJS
module.exports = instantiate;
} else if (typeof define === 'function' && define.amd) { // AMD Module
define('VerEx', [], () => VerbalExpression);
} else { // Browser
this.VerEx = instantiate;
}
When I run the tests in my browser, they all pass.
However, when I run the tests in the terminal, I get errors.
❯ npm test
verbal-expressions#0.3.0 test /Users/shreyasminocha/dev/open source/JSVerbalExpressions
grunt test
Running "qunit:files" (qunit) task
Testing test/index.html FFFFFFFFFFFFFFFFFFFF
>> something
>> Message: Died on test #1 global code#file:///Users/shreyasminocha/dev/open%20source/JSVerbalExpressions/test/tests.js:7:5: Can't find variable: Reflect
>> Actual: null
>> Expected: undefined
>> ExtendableBuiltin#file:///Users/shreyasminocha/dev/open%20source/JSVerbalExpressions/dist/verbalexpressions.js:11:31
>> VerbalExpression#file:///Users/shreyasminocha/dev/open%20source/JSVerbalExpressions/dist/verbalexpressions.js:59:130
>> instantiate#file:///Users/shreyasminocha/dev/open%20source/JSVerbalExpressions/dist/verbalexpressions.js:588:32
>> somethingTest#file:///Users/shreyasminocha/dev/open%20source/JSVerbalExpressions/test/tests.js:8:26
...
Warning: 20 tests completed with 20 failed, 0 skipped, and 0 todo.
20 assertions (in 91ms), passed: 0, failed: 20 Use --force to continue.
Note: I am running the tests on compiled es6 code, that is, I run babel before running the tests.
I am guessing this is something to do with PhantomJS. How do I get the tests to pass in the terminal? Am I missing something? Any workarounds?

Stable PhantomJS doesn't support ES6 and is no longer in development, if possible migrate to puppeteer which is heavily inspired by PhantomJS.

Related

Joining 2 strings in my Gulp file gives a non-sensical error?

Using node 16.2.0 on OSX. I new to Gulp.
I want to update the version in my package.json file that will contain the Git hash if on a feature branch, so I have this in my Gulp file
// pkg is defined somewhere else to be my Gulp file
// I have a "semVer" key in my package.json file
const {src, dest} = require('gulp');
const semver = require('semver');
...
const semVer = semver.parse(pkg.semVer);
// Functions getBranch() and getHash() are defined somewhere else,
// and they return the Git branch and hash respectively.
function manageVersion() {
var newVersion = semver.inc(semVer, 'patch');
var hash = "";
if (getBranch().includes('feature')) {
hash = getHash().toString();
newVersion = [newVersion, hash].join('-');
}
src(['../package*.json'])
.pipe(gulp_bump({
version: newVersion
}))
.pipe(dest('./'));
}
exports.manageVersion = manageVersion
I then do this, and get the non-sensical error
$ gulp manageVersion -f gulpfiles/version.js
[16:20:20] Working directory changed to /path/gulpfiles
[16:20:20] Using gulpfile /path/gulpfiles/version.js
[16:20:20] Starting 'manageVersion'...
[16:20:20] Finished 'manageVersion' after 99 ms
/path/node_modules/semver/semver.js:564
if (v1[key] !== v2[key]) {
^
TypeError: Cannot read property 'major' of null
at Function.diff (/path/node_modules/semver/semver.js:564:27)
at /path/node_modules/bump-regex/index.js:66:26
at String.replace (<anonymous>)
at module.exports (/path/node_modules/bump-regex/index.js:54:23)
at DestroyableTransform._transform (/path/node_modules/gulp-bump/index.js:29:5)
at DestroyableTransform.Transform._read (/path/node_modules/gulp-bump/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/path/node_modules/gulp-bump/node_modules/readable-stream/lib/_stream_transform.js:172:83)
at doWrite (/path/node_modules/gulp-bump/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/path/node_modules/gulp-bump/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at DestroyableTransform.Writable.write (/path/node_modules/gulp-bump/node_modules/readable-stream/lib/_stream_writable.js:334:11)
I've checked ALL my values for newVersion and hash and they're valid strings. What am I missing?
Turns out I had to trim the string from the getHash() function
hash = getHash().trim();

Forge error if using SendStringtoExecute (Command ^C^C)

Actually, the error doesn't raise if I just run (Command ^C^C) from a lisp script.
The case is, my app is a .NET app, and I call some SendStringToExecute to use some lisp code.
To be sure to end the lisp routine, I put at the end:
doc.SendStringToExecute("(Command ^C^C)", True, False, True)
The result of Forge Design Automation is: failedinstruction
Though I can easily find another way to get around this, it cost me more than a day to figure out that it was the (Command ^C^C) cause the failedinstruction, while everything else was working fine.
Hope this bug will be fixed as well as anything similar won't raise up again somewhere else.
I isolate the case like this:
Make a .NET bundle, or just reuse any of your existing one in debug mode
Add the following lisp define function (or it can be a custom command, whatever):
<LispFunction("l+SendStringToExecute")>
Public Shared Function lsp_SendStringToExcute(args As ResultBuffer) As Object
Dim script$ = Nothing
For Each arg As TypedValue In args.AsArray
script = arg.Value
Exit For
Next
script = script.Trim()
If script <> "" Then
Document doc =
AcadApplication.DocumentManager.MdiActiveDocument
doc.SendStringToExecute(script + vbCr, True, False, True)
End If
Return New TypedValue(LispDataType.T_atom)
End Function
Upload the bundle to Forge, create a dump activity and just run the custom lisp solely:
(l+SendStringToExecute "(Command ^C^C)")
The result log is here like this:
...
[02/01/2021 17:23:26] Command: (l+SendStringToExecute "(Command ^C^C)")
[02/01/2021 17:23:26] T
[02/01/2021 17:23:26] Command: (Command ^C^C)
[02/01/2021 17:23:26] *Cancel*
[02/01/2021 17:23:26] Command: nil
[02/01/2021 17:23:27] End AutoCAD Core Engine standard output dump.
[02/01/2021 17:23:27] Error: AutoCAD Core Console failed to finish the script - an unexpected input is encountered.
[02/01/2021 17:23:27] End script phase.
[02/01/2021 17:23:27] Error: An unexpected error happened during phase CoreEngineExecution of job.
[02/01/2021 17:23:27] Job finished with result FailedExecution
[02/01/2021 17:23:27] Job Status:
{
"status": "failedInstructions", ...
Thanks for reporting, I'm not sure if we allow command expression in accoreconsole.
The suggestion is to use following way.
[CommandMethod("CANCELOUTSTANDING")]
public void TESTCANCEL()
{
var doc = Application.DocumentManager.MdiActiveDocument;
string cmd = string.Format("{0}", new string((char)03, 2));
doc.SendStringToExecute(cmd, true, false, true);
}

Migrated from TCL8.4 to 8.5 and Im facing issues with the file sourcing

My application runs well on RHEL 5 (TCL 8.4). But in RHEL 7 64bit TCL8.5, the database files are not sourced in correctly. The application is by default pointing to the last record file in the db. Hence, im assuming it might be issue with the way 8.5 handles the file sourcing. So i created a file X and wrote the below code. (Please ignore dbname and /path, it works fine)
File X
#!/bin/sh
# \
exec tclsh "$0" "$#"
puts [package require Itcl]
namespace import ::itcl::*
puts $itcl::patchLevel
puts $itcl::library
set databases /dbname
set system ($databases,dbpath) /path
source File.class.tcl
source FareFile.class.tcl
puts [Fare.File formtitle]
source Record1File.class.tcl
puts [Fare.File formtitle]
I source FareFile in and print the form title(o/p: Fare Viewer) using the formtitle method which is declared in the File.class.tcl. And then I source Record1File and print the FareFile formtitle (the first one), its printing the form title of Record1File. The formtitle method is returning the value of the lastest sourced file. This does not happen in 8.4
File.class.tcl:
class File {
variable fileinfo
variable recordarray
variable allads_flag 0
variable updates_is_lastkey 0
method formtitle {} {
variable fileinfo
return $fileinfo(formtitle)
}
}
FareFile.class.tcl
FareFile ::Fare.File
::Fare.File parse_fields {
tabtitle "Fares"
formtitle "Fare Viewer"
}
Record1File.class.tcl
Record1File ::Record1.File
::Record1.File parse_fields {
tabtitle "Record 1"
formtitle "Record 1 Viewer"
output in 8.4 / RHEL 5: (Expected output in 8.5)
3.4
3.4.0
/path
Fare Viewer
Fare Viewer
output in 8.5 / RHEL 7:
3.4
3.4.3
/path
Fare Viewer
Record 1 Viewer
If you see the output on both platforms, its different. Please help
(This is only a tentative answer, given all the blanks of the question, but I need the formatting capabilities:)
Try the following pls., by rewriting the body script of method formtitle as follows:
class File {
method formtitle {} {
set v variable
$v fileinfo
return $fileinfo(formtitle)
}
}
... and report back by posting a comment.

using nginx' lua to validate GitHub webhooks and delete cron-lock-file

What I have:
GNU/Linux host
nginx is up and running
there is a cron-job scheduled to run immediately after a specific file has been removed (similar to run-crons)
GitHub sends a webhook when someone pushes to a repository
What I want:
I do now want to run either lua or anything comparable to parse GitHub's request and validate it and then delete a file (if the request was valid of course).
Preferably all of this should happen without the hassle to maintain an additional PHP installation as there is currently none, or the need to use fcgiwrap or similar.
Template:
On the nginx side I have something equivalent to
location /deploy {
# execute lua (or equivalent) here
}
To read json body of GH webhook you nead use JSON4Lua lib, and to validate HMAC signature use luacrypto.
Preconfigure
Install required modules
$ sudo luarocks install JSON4Lua
$ sudo luarocks install luacrypto
In Nginx define location for deploy
location /deploy {
client_body_buffer_size 3M;
client_max_body_size 3M;
content_by_lua_file /path/to/handler.lua;
}
The max_body_size and body_buffer_size should be equal to prevent error
request body in temp file not supported
https://github.com/openresty/lua-nginx-module/issues/521
Process webhook
Get request payload data and check is correct
ngx.req.read_body()
local data = ngx.req.get_body_data()
if not data then
ngx.log(ngx.ERR, "failed to get request body")
return ngx.exit (ngx.HTTP_BAD_REQUEST)
end
Verify GH signature with use luacrypto
local function verify_signature (hub_sign, data)
local sign = 'sha1=' .. crypto.hmac.digest('sha1', data, secret)
-- this is simple comparison, but it's better to use a constant time comparison
return hub_sign == sign
end
-- validate GH signature
if not verify_signature(headers['X-Hub-Signature'], data) then
ngx.log(ngx.ERR, "wrong webhook signature")
return ngx.exit (ngx.HTTP_FORBIDDEN)
end
Parse data as json and check is master branch, for deploy
data = json.decode(data)
-- on master branch
if data['ref'] ~= branch then
ngx.say("Skip branch ", data['ref'])
return ngx.exit (ngx.HTTP_OK)
end
If all correct, call deploy function
local function deploy ()
-- run command for deploy
local handle = io.popen("cd /path/to/repo && sudo -u username git pull")
local result = handle:read("*a")
handle:close()
ngx.say (result)
return ngx.exit (ngx.HTTP_OK)
end
Example
Example constant time string compare
local function const_eq (a, b)
-- Check is string equals, constant time exec
getmetatable('').__index = function (str, i)
return string.sub(str, i, i)
end
local diff = string.len(a) == string.len(b)
for i = 1, math.min(string.len(a), string.len(b)) do
diff = (a[i] == b[i]) and diff
end
return diff
end
A complete example of how I use it in github gist https://gist.github.com/Samael500/5dbdf6d55838f841a08eb7847ad1c926
This solution does not implement verification for GitHub's hooks and assumes you have the lua extension and the cjson module installed:
location = /location {
default_type 'text/plain';
content_by_lua_block {
local cjson = require "cjson.safe"
ngx.req.read_body()
local data = ngx.req.get_body_data()
if
data
then
local obj = cjson.decode(data)
if
# checksum checking should go here
(obj and obj.repository and obj.repository.full_name) == "user/reponame"
then
local file = io.open("<your file>","w")
if
file
then
file:close()
ngx.say("success")
else
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
end
else
ngx.exit(ngx.HTTP_UNAUTHORIZED)
end
else
ngx.exit(ngx.HTTP_NOT_ALLOWED)
end
}
}

nix-shell --command `stack build` leads to libpq-fe.h: No such file or directory

i am trying to compile my small project (a yesod application with lambdacms) on nixos. However, after using cabal2nix (more precisely cabal2nix project-karma.cabal --sha256=0 --shell > shell.nix) , I am still missing a dependency wrt. postgresql it seems.
My shell.nix file looks like this:
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default" }:
let
inherit (nixpkgs) pkgs;
f = { mkDerivation, aeson, base, bytestring, classy-prelude
, classy-prelude-conduit, classy-prelude-yesod, conduit, containers
, data-default, directory, fast-logger, file-embed, filepath
, hjsmin, hspec, http-conduit, lambdacms-core, monad-control
, monad-logger, persistent, persistent-postgresql
, persistent-template, random, resourcet, safe, shakespeare, stdenv
, template-haskell, text, time, transformers, unordered-containers
, uuid, vector, wai, wai-extra, wai-logger, warp, yaml, yesod
, yesod-auth, yesod-core, yesod-form, yesod-static, yesod-test
}:
mkDerivation {
pname = "karma";
version = "0.0.0";
sha256 = "0";
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
aeson base bytestring classy-prelude classy-prelude-conduit
classy-prelude-yesod conduit containers data-default directory
fast-logger file-embed filepath hjsmin http-conduit lambdacms- core
monad-control monad-logger persistent persistent-postgresql
persistent-template random safe shakespeare template-haskell text
time unordered-containers uuid vector wai wai-extra wai-logger warp
yaml yesod yesod-auth yesod-core yesod-form yesod-static
nixpkgs.zlib
nixpkgs.postgresql
nixpkgs.libpqxx
];
libraryPkgconfigDepends = [ persistent-postgresql];
executableHaskellDepends = [ base ];
testHaskellDepends = [
base classy-prelude classy-prelude-yesod hspec monad-logger
persistent persistent-postgresql resourcet shakespeare transformers
yesod yesod-core yesod-test
];
license = stdenv.lib.licenses.bsd3;
};
haskellPackages = if compiler == "default"
then pkgs.haskellPackages
else pkgs.haskell.packages.${compiler};
drv = haskellPackages.callPackage f {};
in
if pkgs.lib.inNixShell then drv.env else drv
The output is as follows:
markus#nixos ~/git/haskell/karma/karma (git)-[master] % nix-shell --command `stack build`
postgresql-libpq-0.9.1.1: configure
ReadArgs-1.2.2: download
postgresql-libpq-0.9.1.1: build
ReadArgs-1.2.2: configure
ReadArgs-1.2.2: build
ReadArgs-1.2.2: install
-- While building package postgresql-libpq-0.9.1.1 using:
/run/user/1000/stack31042/postgresql-libpq-0.9.1.1/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/setup/setup --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/ build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /home/markus/git/haskell/karma/karma/.stack-work/logs/postgresql-libpq-0.9.1.1.log
[1 of 1] Compiling Main ( /run/user/1000/stack31042/postgresql-libpq-0.9.1.1/Setup.hs, /run/user/1000/stack31042/postgresql-libpq-0.9.1.1/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/setup/Main.o )
Linking /run/user/1000/stack31042/postgresql-libpq-0.9.1.1/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/setup/setup ...
Configuring postgresql-libpq-0.9.1.1...
Building postgresql-libpq-0.9.1.1...
Preprocessing library postgresql-libpq-0.9.1.1...
LibPQ.hsc:213:22: fatal error: libpq-fe.h: No such file or directory
compilation terminated.
compiling .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Database/PostgreSQL/LibPQ_hsc_make.c failed (exit code 1)
command was: /nix/store/9fbfiij3ajnd3fs1zyc2qy0ispbszrr7-gcc-wrapper-4.9.3/bin/gcc -c .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Database/PostgreSQL/LibPQ_hsc_make.c -o .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Database/PostgreSQL/LibPQ_hsc_make.o -fno-stack-protector -D__GLASGOW_HASKELL__=710 -Dlinux_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dlinux_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -I/run/current-system/sw/include -Icbits -I.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen -include .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h -I/nix/store/xphvly2zcd6jsc2xklz1zmmz4y0dh3ny-ghc-7.10.2/lib/ghc-7.10.2/bytes_6elQVSg5cWdFrvRnfxTUrH/include -I/nix/store/xphvly2zcd6jsc2xklz1zmmz4y0dh3ny-ghc-7.10.2/lib/ghc-7.10.2/base_GDytRqRVSUX7zckgKqJjgw/include -I/nix/store/6ykqcjxr74l642kv9gf1ib8v9yjsgxr9-gmp-5.1.3/include -I/nix/store/xphvly2zcd6jsc2xklz1zmmz4y0dh3ny-ghc-7.10.2/lib/ghc-7.10.2/integ_2aU3IZNMF9a7mQ0OzsZ0dS/include -I/nix/store/xphvly2zcd6jsc2xklz1zmmz4y0dh3ny-ghc-7.10.2/lib/ghc-7.10.2/include -I/nix/store/xphvly2zcd6jsc2xklz1zmmz4y0dh3ny-ghc-7.10.2/lib/ghc-7.10.2/include/
I assume not much is missing, so a pointer would be nice.
What is also weird, that is that "nix-shell" works but following that up with "stack exec yesod devel" tells me
Resolving dependencies...
Configuring karma-0.0.0...
cabal: At least the following dependencies are missing:
classy-prelude >=0.10.2,
classy-prelude-conduit >=0.10.2,
classy-prelude-yesod >=0.10.2,
hjsmin ==0.1.*,
http-conduit ==2.1.*,
lambdacms-core >=0.3.0.2 && <0.4,
monad-logger ==0.3.*,
persistent >=2.0 && <2.3,
persistent-postgresql >=2.1.1 && <2.3,
persistent-template >=2.0 && <2.3,
uuid >=1.3,
wai-extra ==3.0.*,
warp >=3.0 && <3.2,
yesod >=1.4.1 && <1.5,
yesod-auth >=1.4.0 && <1.5,
yesod-core >=1.4.6 && <1.5,
yesod-form >=1.4.0 && <1.5,
yesod-static >=1.4.0.3 && <1.6
When using mysql instead, I am getting
pcre-light-0.4.0.4: configure
mysql-0.1.1.8: configure
mysql-0.1.1.8: build
Progress: 2/59
-- While building package mysql-0.1.1.8 using:
/run/user/1000/stack12820/mysql-0.1.1.8/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/setup/setup --builddir=.stack-work/dist/x86_64- linux/Cabal-1.22.4.0/ build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /home/markus/git/haskell/karma/karma/.stack-work/logs/mysql-0.1.1.8.log
[1 of 1] Compiling Main ( /run/user/1000/stack12820/mysql-0.1.1.8/Setup.lhs, /run/user/1000/stack12820/mysql-0.1.1.8/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/setup/Main.o )
Linking /run/user/1000/stack12820/mysql-0.1.1.8/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/setup/setup ...
Configuring mysql-0.1.1.8...
Building mysql-0.1.1.8...
Preprocessing library mysql-0.1.1.8...
In file included from C.hsc:68:0:
include/mysql_signals.h:9:19: fatal error: mysql.h: No such file or directory
#include "mysql.h"
^
compilation terminated.
compiling .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Database/MySQL/Base/C_hsc_make.c failed (exit code 1)
command was: /nix/store/9fbfiij3ajnd3fs1zyc2qy0ispbszrr7-gcc-wrapper-4.9.3/bin/gcc -c .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Database/MySQL/Base/C_hsc_make.c -o .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Database/MySQL/Base/C_hsc_make.o -fno-stack-protector -D__GLASGOW_HASKELL__=710 -Dlinux_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dlinux_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -I/nix/store/7ppa4k2drrvjk94rb60c1df9nvw0z696-mariadb-10.0.22-lib/include -I/nix/store/7ppa4k2drrvjk94rb60c1df9nvw0z696-mariadb-10.0.22-lib/include/.. -Iinclude -I.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen -include .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h -I/nix/store/xphvly2zcd6jsc2xklz1zmmz4y0dh3ny-ghc-7.10.2/lib/ghc-7.10.2/bytes_6elQVSg5cWdFrvRnfxTUrH/include -I/nix/store/xphvly2zcd6jsc2xklz1zmmz4y0dh3ny-ghc-7.10.2/lib/ghc-7.10.2/base_GDytRqRVSUX7zckgKqJjgw/include -I/nix/store/6ykqcjxr74l642kv9gf1ib8v9yjsgxr9-gmp-5.1.3/include -I/nix/store/xphvly2zcd6jsc2xklz1zmmz4y0dh3ny-ghc-7.10.2/lib/ghc-7.10.2/integ_2aU3IZNMF9a7mQ0OzsZ0dS/include -I/nix/store/xphvly2zcd6jsc2xklz1zmmz4y0dh3ny-ghc-7.10.2/lib/ghc-7.10.2/include -I/nix/store/xphvly2zcd6jsc2xklz1zmmz4y0dh3ny-ghc-7.10.2/lib/ghc-7.10.2/include/
-- While building package pcre-light-0.4.0.4 using:
/home/markus/.stack/setup-exe-cache/setup-Simple-Cabal-1.22.4.0-x86_64-linux-ghc-7.10.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/ configure --with-ghc=/run/current-system/sw/bin/ghc --user --package-db=clear --package-db=global --package-db=/home/markus/.stack/snapshots/x86_64-linux/nightly-2015-11-17/7.10.2/pkgdb/ --libdir=/home/markus/.stack/snapshots/x86_64-linux/nightly-2015-11-17/7.10.2/lib --bindir=/home/markus/.stack/snapshots/x86_64-linux/nightly-2015-11-17/7.10.2/bin --datadir=/home/markus/.stack/snapshots/x86_64-linux/nightly-2015-11-17/7.10.2/share --libexecdir=/home/markus/.stack/snapshots/x86_64-linux/nightly-2015-11-17/7.10.2/libexec --sysconfdir=/home/markus/.stack/snapshots/x86_64-linux/nightly-2015-11-17/7.10.2/etc --docdir=/home/markus/.stack/snapshots/x86_64-linux/nightly-2015-11-17/7.10.2/doc/pcre-light-0.4.0.4 --htmldir=/home/markus/.stack/snapshots/x86_64-linux/nightly-2015-11-17/7.10.2/doc/pcre-light-0.4.0.4 --haddockdir=/home/markus/.stack/snapshots/x86_64-linux/nightly-2015-11-17/7.10.2/doc/pcre-light-0.4.0.4 --dependency=base=base-4.8.1.0-4f7206fd964c629946bb89db72c80011 --dependency=bytestring=bytestring-0.10.6.0-18c05887c1aaac7adb3350f6a4c6c8ed
Process exited with code: ExitFailure 1
Logs have been written to: /home/markus/git/haskell/karma/karma/.stack-work/logs/pcre-light-0.4.0.4.log
Configuring pcre-light-0.4.0.4...
setup-Simple-Cabal-1.22.4.0-x86_64-linux-ghc-7.10.2: The program 'pkg-config'
version >=0.9.0 is required but it could not be found.
After adding pkgconfig to my global configuration, the build seems to get a little further ahead, so it seems that shell.nix is ignored somewhat.
(Sources for what I tried so far:
https://groups.google.com/forum/#!topic/haskell-stack/_ZBh01VP_fo)
Update: It seems like I overlooked this section of the manual
http://nixos.org/nixpkgs/manual/#using-stack-together-with-nix
However, the first idea that came to mind
(stack --extra-lib-dirs=/nix/store/c6qy7n5wdwl164lnzha7vpc3av9yhnga-postgresql-libpq-0.9.1.1/lib build)
did not work yet, most likely I need to use
--extra-include-dirs or try one of the variations. It seems weird that stack is still trying to build postgresql-libpq in the very same version, though.
Update2: Currently trying out "stack --extra-lib-dirs=/nix/store/1xf77x47d0m23nbda0azvkvj8w8y77c7-postgresql-9.4.5/lib --extra-include-dirs=/nix/store/1xf77x47d0m23nbda0azvkvj8w8y77c7-postgresql-9.4.5/include build" which looks promising. Does not look like the nix-way, but still.
Update3: Still getting
<command line>: can't load .so/.DLL for: /home/markus /.stack/snapshots/x86_64-linux/nightly-2015-11-17/7.10.2/lib/x86_64-linux- ghc-7.10.2/postgresql-libpq-0.9.1.1-ABGs5p1J8FbEwi6uvHaiV6/libHSpostgresql-libpq-0.9.1.1-ABGs5p1J8FbEwi6uvHaiV6-ghc7.10.2.so
(libpq.so.5: cannot open shared object file: No such file or directory) stack build 186.99s user 2.93s system 109% cpu 2:52.76 total
which is strange since libpq.so.5 is contained in /nix/store/1xf77x47d0m23nbda0azvkvj8w8y77c7-postgresql-9.4.5/lib.
An additional
$LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/nix/store/1xf77x47d0m23nbda0azvkvj8w8y77c7-postgresql-9.4.5/lib
does not help either.
Update4:
By the way, yesod devel does the same as stack exec yesod devel. My libraries are downloaded to /nix/store but they are not recognized.
Maybe I need to make "build-nix" work and yesod devel does not work here?
Just for completeness, here is stack.yaml
resolver: nightly-2015-11-17
#run stack setup otherwise!!
# Local packages, usually specified by relative directory name
packages:
- '.'
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps: [lambdacms-core-0.3.0.2 , friendly-time-0.4, lists-0.4.2, list-extras-0.4.1.4 ]
# Override default flag values for local packages and extra-deps
flags:
karma:
library-only: false
dev: false
# Extra package databases containing global packages
extra-package-dbs: []
Next weekend, I will check out
https://pr06lefs.wordpress.com/2014/09/27/compiling-a-yesod-project-on-nixos/
and other search results.
Funny, because I've just had a similar problem myself - solved it by adding these two lines to stack.yaml:
extra-include-dirs: [/nix/store/jrdvjvf0w9nclw7b4k0pdfkljw78ijgk-postgresql-9.4.5/include/]
extra-lib-dirs: [/nix/store/jrdvjvf0w9nclw7b4k0pdfkljw78ijgk-postgresql-9.4.5/lib/]
You may want to check first which postgresql's path from the /nix/store you should use with include/ and lib/:
nix-build --no-out-link "<nixpkgs>" -A postgresql
And BTW, why do you use nix-shell if you are going to use stack and you have project-karma.cabal available..? Have you considered migrating your project with stack init..?
Looks like stack is trying to build haskellPackages.postgresql-libpq outside of the nix framework.
You probably don't want that to happen. Maybe try to add postgresql-libpq to libraryHaskellDepends?