Run gulp via cake Start-Process - gulp

I'm building site via gulp inside a windows container:
mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-1909
The container have nodejs and gulp-cli installed in it as following (in Dockerfile):
#Install NodeJs
RUN (New-Object Net.WebClient).DownloadFile('https://nodejs.org/dist/v12.16.3/node-v12.16.3-win-x64.zip', 'node.zip'); \
Expand-Archive -LiteralPath 'node.zip' -DestinationPath '.' ; \
Start-Process -FilePath '.\node-v12.16.3-win-x64\npm' -NoNewWindow -Wait -ArgumentList 'install -g gulp-cli' ; \
$env:PATH = 'c:\tools\node-v12.16.3-win-x64;' + $env:PATH; \
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine);
As you can see I'm installing node in the container under c:\tools\node-v12.16.3-win-x64.
In my cake script i try to execute gulp file as following:
StartProcess("cmd", new ProcessSettings {
Arguments = "/c gulp",
WorkingDirectory = projectDir)
});
But seems that Start-Process cannot find the file... I'm getting this output from cake Start-Process:
Executing: "cmd" /c gulp
'gulp' is not recognized as an internal or external command
Running the container interactive I can see the file it is in that place and if I run gulp from projectDir all works.
I've also try it to run it like all of the following forms without success:
StartProcess("powershell", new ProcessSettings {
Arguments = "gulp",
WorkingDirectory = projectDir)
});
StartProcess("gulp");
StartProcess("gulp.cmd");
This is the output from within the container regarding npn, gulp versions (requested from comments):

EDIT:
That 'Local version: Unknown' seems off. Is C:\code your project directory?
When I look at the 'official' gulp configuration steps, the installation results in having both a CLI and local version.
(see: https://gulpjs.com/docs/en/getting-started/quick-start/ )
You could consider using Cake.Gulp which can help run gulp with cake either from a local or global installation:
Namespace: https://cakebuild.net/api/Cake.Gulp/
Example usage: https://cake-contrib.github.io/Cake.Gulp/docs/usage/examples
Perhaps making sure that npm installed gulp locally might do the trick because cake is expecting a local variant. I am unfortunately inexperienced with cake, so this is my best guess after doing some basic research.
(one of my sources: Why do we need to install gulp globally and locally? )
Original answer
You could try using an absolute path to the gulp application.
For example:
StartProcess("cmd", new ProcessSettings {
Arguments = "/c c:\tools\node-v12.16.3-win-x64\gulp",
WorkingDirectory = projectDir)
});
It could be that your environment is not set properly, I found this that could be of use: Appending to PATH in a Windows Docker container

Related

Can not deploy Go in Oracle Cloud Function using Cloud Shell

I tried to Creating and Deploying Oracle Cloud Functions by following the official documentation instructions. I can create and deploy using java runtime but when I deploy go runtime always return error.
I tried to init Go function using this command in Oracle Cloud Shell:
fn init --runtime go hello-go
then I tried to deploy it
fn -v deploy --app test
but it returned error like below:
Deploying hello-go to app: test
Bumped to version 0.0.7
Building image bom.ocir.io/bmptwl2psusa/repo/hello-go:0.0.7
FN_REGISTRY: bom.ocir.io/bmptwl2psusa/repo
Current Context: ap-mumbai-1
Sending build context to Docker daemon 5.632kB
Step 1/10 : FROM fnproject/go:dev as build-stage
---> 96c8fb94a8e1
Step 2/10 : WORKDIR /function
---> Using cache
---> 8961dd299ec1
Step 3/10 : WORKDIR /go/src/func/
---> Using cache
---> 5a4c2c6e13f1
Step 4/10 : ENV GO111MODULE=on
---> Using cache
---> 22022ff2fcf8
Step 5/10 : COPY . .
---> 714622a6ff03
Step 6/10 : RUN cd /go/src/func/ && go build -o func
---> Running in 39fedbc476f4
build func: cannot find module for path github.com/fnproject/fdk-go
The command '/bin/sh -c cd /go/src/func/ && go build -o func' returned a non-zero code: 1
Fn: error running docker build: exit status 1
When I'm using java runtime with fn init --runtime java hello-java command, it's successfully deployed, Why always fail when using go?
I tried to run go build -o func in hello-go directory but it's returned:
go: finding module for package github.com/fnproject/fdk-go
go: writing stat cache: mkdir /usr/share/gocode/pkg: permission denied
go: downloading github.com/fnproject/fdk-go v0.0.3
func.go:10:2: mkdir /usr/share/gocode/pkg: permission denied
I know it happened because /usr/share/gocode/ directory is under root user, but I dont know how to change the permission on that folder because Oracle Cloud Shell can not use root user or sudo. (based on this answer)
Maybe I can do it if I use real VM shell or local shell/terminal, but I want to use Oracle Cloud Shell because I just followed official instructions that suggested me using Oracle Cloud Shell, so how to deploy Oracle Cloud Functions with Go runtime using Oracle Cloud Shell?
Mostly the official documentations only give the examples using Java runtime, that make me paranoid when using go.
This is a bug in cloudshell that we are figuring out the best way to solve.
As a short-term workaround you can do this once:
mkdir ${HOME}/gopath
Then set this in your terminal:
export GOPATH=${HOME}/gopath
You should probably edit your ~/.bashrc to set the GOPATH variable automatically so you don't forget

Why rustc did not include libmariadb into release binary?

I thought rust compiler uses static binding and includes all the dependent libraries at compile time (hence executable size).
But when I've tried to use compiled binary in a docker scratch image with actix, mysql client and diesel with mysql feature enabled this error pops up:
error while loading shared libraries: libmariadb.so.3: cannot open shared object file: No such file or director
My dockerfile:
FROM rust:1.43 as builder
WORKDIR /var/app
RUN apt-get update && apt-get install -y libclang-dev clang libmariadb-dev-compat libmariadb-dev
COPY Cargo.toml Cargo.lock diesel.toml ./
COPY src src
RUN cargo install diesel_cli --no-default-features --features mysql
RUN cp /usr/local/cargo/bin/diesel diesel
RUN cargo build --release
FROM ubuntu
USER 1000
WORKDIR /var/app
COPY --from=builder --chown=1000:1000 /var/app/target/release/sniper_api app
COPY --from=builder --chown=1000:1000 /var/app/diesel diesel
CMD ["./app"]
My cargo:
[dependencies]
actix-rt = "1.0.0"
actix-web = "2.0.0"
actix-http = "1.0.1"
serde = { version = "1.0.112", features=["derive"] }
dotenv = "0.15.0"
config = "0.10.1"
diesel = { version = "1.4.2", features = ["mysql","r2d2"]}
futures = "0.3.5"
r2d2 = "0.8.8"
r2d2_mysql = "18.0.0"
env_logger = "0.7.1"
But if I use ubuntu/debian/etc. image as runtime and install libmariadb-dev-compat libmariadb-dev everything is fine. Is there a way to get true single binary with mysql connector in Rust?
I thought rust compiler uses static binding and includes all the dependent libraries at compile time (hence executable size).
This only applies for Rust libraries. For other languages, there is generally little rustc can do.
In particular in this case, diesel provides mysql/mariadb support via the mysqlclient-sys crate for which there currently is an issue and an accompanying PR open to support static linking for this library. But they haven't been merged yet.

Using Compass watch In Non-Rails project Hangs

I'm using compass with a non-Rails project. I have a config file at:
config/compass.rb
My config file looks like this:
http_path = "/"
css_dir = "./example"
sass_dir = "./example/sass"
images_dir = "./example/images"
javascripts_dir = "./example/js"
output_style = :compressed
relative_assets = true
And I'm starting Compass using:
compass watch -c config/compass.rb
When I run this, compass just hangs. If I run compass using --trace and quit, I get the following stack-trace:
^CInterrupt on line ["18"] of /Users/me/.gem/ruby/2.0.0/gems/compass-rails-2.0.0/lib/compass-rails.rb:
/Users/me/.gem/ruby/2.0.0/gems/compass-rails-2.0.0/lib/compass-rails.rb:116:in `configuration'
/Users/me/.gem/ruby/2.0.0/gems/compass-1.0.0.rc.1/lib/compass/configuration/helpers.rb:21:in `configuration_for'
/Users/me/.gem/ruby/2.0.0/gems/compass-core-1.0.0.rc.1/lib/compass/configuration.rb:139:in `add_configuration'
/Users/me/.gem/ruby/2.0.0/gems/compass-1.0.0.rc.1/lib/compass/configuration/helpers.rb:79:in `add_project_configuration'
/Users/me/.gem/ruby/2.0.0/gems/compass-1.0.0.rc.1/lib/compass/commands/project_base.rb:37:in `add_project_configuration'
/Users/me/.gem/ruby/2.0.0/gems/compass-1.0.0.rc.1/lib/compass/commands/project_base.rb:25:in `configure!'
/Users/me/.gem/ruby/2.0.0/gems/compass-1.0.0.rc.1/lib/compass/commands/project_base.rb:15:in `initialize'
/Users/me/.gem/ruby/2.0.0/gems/compass-1.0.0.rc.1/lib/compass/commands/update_project.rb:41:in `initialize'
So it appears that rather than using the compass gem, calling compass watch is using compass-rails which expects configuration arguments I'm not supplying and hangs.
$ which compass returns: /Users/me/.gem/ruby/2.0.0/bin/compass
Why is this and how can I work around it?
To get this working I used Bundler and ran:
$ be compass watch -c ./config/compass.rb
Note be is an alias for bundle exec.
I'm still unsure how compass-rails was hooking into compass.

Cmake linking to mysql & curl, LNK2019

Ok so I just started playing around with CMake. I'm trying to build a project which has dependencies on both MySQL and CURL. This is the directory structure:
./
./src
./cmake
CMakeLists.txt
It's really that simple, src only contains 9 Cpp files and a CMakeLists.txt.
When running CMake, everything works fine. I just get a bunch of linker errors due to MySQL and CURL not being effectively linked. What am I doing wrong ?
Root CMakeLists.txt:
PROJECT(IRCBot)
INCLUDE(CPack)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindCURL.cmake)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
FIND_PACKAGE(CURL)
IF(CURL_FOUND)
MESSAGE(STATUS "Curl libraries found at: ${CURL_LIBRARIES}")
MESSAGE(STATUS "Curl includes found at: ${CURL_INCLUDE_DIRS}")
else()
MESSAGE(SEND_ERROR "Could not find cURL on your system")
ENDIF(CURL_FOUND)
FIND_PACKAGE(MySQL)
IF(MYSQL_FOUND)
MESSAGE(STATUS "MySQL found at: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
ELSE(MYSQL_FOUND)
MESSAGE(SEND_ERROR "Couldn't find MySQL include files and/or library")
ENDIF(MYSQL_FOUND)
ADD_SUBDIRECTORY(src)
And ./src/CMakeLists.txt
FILE(GLOB_RECURSE IRCBot_files *.cpp *.h)
SET(IRCBot_src
${IRCBot_files}
)
INCLUDE_DIRECTORIES(
${CURL_INCLUDE_DIRS}
${MYSQL_INCLUDE_DIR}
)
LINK_DIRECTORIES(
${MYSQL_LIBRARIES}
${CURL_LIBRARIES}
)
ADD_EXECUTABLE(IRCBot ${IRCBot_src})
INSTALL(TARGETS IRCBot DESTINATION ${INSTALL_DIR}/bin)
You don't need LINK_DIRECTORIES() call in this case, since it tells compiler where to find libs.
Instead, use
TARGET_LINK_LIBRARIES(IRCBot
${MYSQL_LIBRARIES}
${CURL_LIBRARIES})
because ${MYSQL_LIBRARIES} contains absolute paths.

Installation error for DBD::MySQL on OSX v10.6.6

I'm attempting to get DBD::MySQL working on Snow Leopard (v10.6.6). The default version of Perl that comes with the OS is v5.10.0. Since I've read that's 64-bit, I went ahead and downloaded and installed a 64-bit version of MySQL (mysql-5.5.8-osx10.6-x86_64).
Installing and setting up MySQL went smoothly, here's my config and version number for reference.
I used CPAN to download DBI and the DBD::MySQL drivers. I then:
Installed DBI
Setup a Makefile.PL
Ran the make command from the command line
The Makefile.PL said it would use the following settings for compiling and testing:
I will use the following settings for compiling and testing:
cflags (mysql_config ) = -I/usr/local/mysql/include -Os -g -fno-common -fno-strict-aliasing -arch x86_64
embedded (mysql_config ) =
libs (mysql_config ) = -L/usr/local/mysql/lib -lmysqlclient -lpthread
mysql_config (guessed ) = mysql_config
nocatchstderr (default ) = 0
nofoundrows (default ) = 0
ssl (guessed ) = 0
testdb (default ) = test
testhost (default ) =
testpassword (User's choice) = r00t!
testsocket (default ) =
testuser (User's choice) = root
To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.
Multiple copies of Driver.xst found in: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/DBI/ at Makefile.PL line 907
Using DBI 1.616 (for perl 5.010000 on darwin-thread-multi-2level) installed in /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/
Writing Makefile for DBD::mysql
Everything seemed to be going fine, until I tried to run make test :
t/00base....................NOK 2/6# Tried to use 'DBD::mysql'.
# Error: Can't load '/Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.16.dylib
# Referenced from: /Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle
# Reason: image not found at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/DynaLoader.pm line 207.
# at (eval 7) line 2
# Compilation failed in require at (eval 7) line 2.
# BEGIN failed--compilation aborted at (eval 7) line 2.
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 9
It's failing because it can't seem to find the mysql.bundle for DBD. Has anyone come across this problem? Or can point me in the right direction on what to try next? I need DBI/DBD::MySQL for my new job and I'm scrambling to find a solution.
Many thanks in advance.
I got around the "Library not loaded: libmysqlclient.16.dylib" problem by placing a symbolic link in /usr/lib/" to /usr/local/mysql-5.5.8-osx10.6-x86_64/lib/libmysqlclient.16.dylib
I worked around the same or a similar issue. Somehow I could build and test DBD::mysql with cpan but when I tried to use it in a script it said things like
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
Expected in: flat namespace
Apparently, it's a 64-bit vs 32-bit issue.
Installing the fink dbd-mysql-pm5100 package made it work though it took kind of a long time. I also removed the cpan-installed version:
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql.pm
also include in .profile
export VERSIONER_PERL_PREFER_32_BIT=yes;
Besides creating the link the executions of the program with DBI::mysql generated an error, thus including this variable on the environment make it works
I know this is an old post. But I suppose the best solution would be to add the library directory to the DYLD_FALLBACK_LIBRARY_PATH env variable. (reason here: https://stackoverflow.com/a/3172515/119958 )
There is no ldconfig in mac, so just add the path to this env var and rerun the install process for DBD::mysql
Donato-Vianas-MacBook-Pro:Invoicer donato$ cpanm DBD::mysql
--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz ... OK
Configuring DBD-mysql-4.022 ... OK
Building and testing DBD-mysql-4.022 ... FAIL
! Installing DBD::mysql failed. See /Users/donato/.cpanm/build.log for details.
# Failed test 'use DBD::mysql;'
# at t/00base.t line 21.
# Tried to use 'DBD::mysql'.
# Error: Can't load '/Users/donato/.cpanm/work/1359948144.491/DBD-mysql-4.022/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/donato/.cpanm/work/1359948144.491/DBD-mysql-4.022/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.18.dylib
Donato-Vianas-MacBook-Pro:Invoicer donato$ export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH
Donato-Vianas-MacBook-Pro:Invoicer donato$ cpanm DBD::mysql--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz ... OK
Configuring DBD-mysql-4.022 ... OK
Building and testing DBD-mysql-4.022 ... OK
Successfully installed DBD-mysql-4.022
1 distribution installed
Donato's solution works for install, but the var has to be present at runtime as well or I get the same error. The following fixes this at runtime for shell and _www user:
# For command line use, add following line to ~/.bash_profile:
export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH
# If Apache needs it, add following line to /etc/apache2/httpd.conf:
# On Lion Server, I put it after <IfDefine MACOSXSERVER>, but shouldn't matter
SetEnv DYLD_FALLBACK_LIBRARY_PATH /usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH
It's somewhat of an aside, but I strongly recommend setting up a separate perl on the machine -- either by fink / macports, or from source -- and leaving the Mac's system perl (and its libraries) alone.
Once I did this on my own Mac, I had very few troubles installing modules thereafter, and I didn't have to worry about accidentally blowing a hole in my OS by breaking the perl that the system uses.
If it were my Mac, I'd install a new perl from source (the Perl source distribution is smart enough to install itself see that it's on a Mac and install itself safely into /usr/local/bin) and the proceed from thee to install DBD::Mysql (and the other modules you require).