Not able to launch heroku cli on cygwin - heroku

As I don't have admin rights on my laptop, so downloaded the zip version of heroku CLI for deploying my app. When I execute the cmd from the bin path of the heroku it's launching and working fine, but when trying to launch from cygwin it's not working. Followed below workaround as I thought path issues, symlinks issues
.bash_profile
#Setting the heroku path on the cygwin
export PATH=$PATH:"/cygdrive/c/Django/heroku/bin/heroku"
export CYGWIN="winsymlinks:native"
cd C:/cygdrive && rm -rf c && ln -s -v C:/ c
.bashrc
alias heroku="/cygdrive/c/Django/heroku/bin/heroku"
which are suggested in the SO, but not helpful and I'm getting below error when trying to execute $ heroku in cygwin..
$ heroku
internal/modules/cjs/loader.js:983
throw err;
^
Error: Cannot find module 'C:\cygdrive\c\Django\heroku\bin\run'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980
:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_ma
in.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Note: I'm able to launch heroku from GIT bash and CMD

whole time I was adding wrong files to the path and also executing them, Extracted zip folder of heroku contains following files
So, what I did..? copied the full path of bin including heroku.cmd file and pasted in the below file ".bashrc" as alias.
.bashrc
alias heroku="/cygdrive/c/Django/heroku/bin/heroku.cmd"
as heroku.cmd file is a script file and it contains set of commands for the heroku.
and I'm able to login to heroku and create app as well.

Related

Build kustomize 3.2.0 on Windows

Can someone suggest how to install 3.2.0 version of kustomize on Windows, please?
I need specifically v3.2.0 on Windows. I am following this tutorial.
Source code: https://github.com/kubernetes-sigs/kustomize/releases/tag/v3.2.0
I downloaded the zip file and installed Go. However when I run go install . inside that kustomize folder i get: no Go files in path/kustomize/..
Also tried step by step aforementioned tutorial but same error..
EDIT: Trying to install via https://github.com/kubernetes-sigs/kustomize/blob/master/hack/install_kustomize.sh ./install_kustomize.sh 3.2.0 I get: Version v3.2.0 does not exist.
When I try ./install_kustomize.sh 3.2.1 I get:
tar (child): ./kustomize_v*_windows_amd64.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Env: Windows 10, executing in GIT Bash
You'll need to run go install ./cmd/kustomize/.
That is where the main.go is you want built.
This will install the executable in your %GOBIN%.
You might want to use go build -o kustomize.exe ./cmd/kustomize/ instead to get the executable in your current working directory.

What is the right way to source .sh file after auto deployment to azure linux webapp?

I have a laravel application on my azure webapp (linux).
I am trying to run some php commands after deploying.
I am using Local Git to deploy to my azure's webapp.
and as per this guide, i set the "POST_BUILD_SCRIPT_PATH" to run a script named "postbuild.sh"
(Note that i am using a .sh file since i am in a Linux based webapp. )
The problem is my postbuild.sh location is in "wwwroot" (where my laravel root application is).
but i keep getting the
Could not open input file: artisan
message when i try to run any artisan command like
php artisan cache:clear
After looking up, i found that the script is being executed from a tmp location.
and i should use sourcing for running the script in the right location but it is still doesn't work.
so i created another .sh file in 'wwwroot' as well named 'clearcache.sh' and tried to source it in 'postbuild.sh' but still not working.
My postbuild.sh is
echo "Post Build .sh"
echo "Script executed from: ${PWD}"
BASEDIR=$(dirname $0)
echo "Script location: ${BASEDIR}"
echo "===================="
source ./home/site/wwwroot/refresh.sh
My refresh.sh is
echo "Refresh script"
echo "Script executed from: ${PWD}"
BASEDIR=$(dirname $0)
echo "Script location: ${BASEDIR}"
php artisan cache:clear
and the errors i am having when pushing to azure repo is:
remote: Detecting platforms...
remote: Detected following platforms:
remote: php: 7.4.24
remote:
remote: Using intermediate directory '/tmp/8d9a71074a40f5b'.
remote:
remote: Copying files to the intermediate directory...
remote: Done in 0 sec(s).
remote: /home/site/wwwroot/postbuild.sh: line 6: ./home/site/wwwroot/refresh.sh
remote:
remote: : No such file or directory
remote: Source directory : /tmp/8d9a71074a40f5b
remote: Destination directory: /home/site/wwwroot
remote:
remote: Executing pre-build command...
remote: Pre Build
remote: Finished executing pre-build command.
remote: PHP executable: /tmp/oryx/platforms/php/7.4.24/bin/php
remote: No 'composer.json' file found; not running 'composer install'.
remote:
remote: Executing post-build command...
remote: Post Build .sh
remote: Script executed from: /tmp/8d9a71074a40f5b
remote: Script location: /home/site/wwwroot
remote:
remote: ====================
Please note the following:
Laravel root directory doesn't contain 'index.php' file, but i added a
dummy 'index.php' file anyway because it was needed by Azure to
validate the build.
I removed the 'composer.json' file from the local git because i didn't
need to run composer install. i just wanted to copy app & routes
folder from the repo folder to 'wwwroot'
You never actually switch to the BASEDIR by doing e.g. cd $BASEDIR so your working directory never actually changes so here's one way around this:
echo "Refresh script"
echo "Script executed from: ${PWD}"
BASEDIR=$(dirname $0)
echo "Script location: ${BASEDIR}"
$(
cd $BASEDIR
php artisan cache:clear
)
Note the multiline $(...) is to execute the contents but preserve the original working directory when complete.
Alternatively you can do:
echo "Refresh script"
echo "Script executed from: ${PWD}"
BASEDIR=$(dirname $0)
echo "Script location: ${BASEDIR}"
php $BASEDIR/artisan cache:clear
I achieved what i was looking for using a different approach.
I used the Custom Deployment Script. (as per this link)
The Custom Deployment let you totally handle the deployment process yourself.
So i wrote a script to copy the files from the repo to the wwwroot.
But i faced another issue which is the php-cli that the kudu runs doesn't include any database modules as per this issue i found at the kudu's repo.
So, i came with a solution to run my artisan commands(which are mainly cache refreshing)
programtically using Laravel Controller. and curl HTTP Request to call this link to execute the
artisan commands using this controller.
Not the ideal solution. but it works
Here is my .deployment file
[config]
command = ./deploy.sh
and here is my deploy.sh
rm -rf $DEPLOYMENT_TARGET/app
rm -rf $DEPLOYMENT_TARGET/resources
rm -rf $DEPLOYMENT_TARGET/routes
rm -rf $DEPLOYMENT_TARGET/public/*.js
rm -rf $DEPLOYMENT_TARGET/public/*.svg
rm -rf $DEPLOYMENT_TARGET/public/*.eot
rm -rf $DEPLOYMENT_TARGET/public/*.css
rm -rf $DEPLOYMENT_TARGET/public/*.ico
rm -rf $DEPLOYMENT_TARGET/public/*.woff2
rm -rf $DEPLOYMENT_TARGET/public/*.woff
rm -rf $DEPLOYMENT_TARGET/public/*.ttf
\cp -RTf $DEPLOYMENT_SOURCE $DEPLOYMENT_TARGET
rm -rf $DEPLOYMENT_SOURCE/app
rm -rf $DEPLOYMENT_SOURCE/resources
rm -rf $DEPLOYMENT_SOURCE/routes
rm -rf $DEPLOYMENT_SOURCE/public
php /home/site/wwwroot/refresh-app.php
You can call the link to refresh the artisan commands inside refresh-app.php using curl or any other favorite way.

How to locate and view detailed Heroku log files?

My Heroku app is not running. When I view the log files on the website, there is a reference to what I believe is a different more detailed log file.
I connected to Heroku via bash and tried to traverse to the ".npm/" directory, but it does not exist. Where do I find this log file?
2018-02-11T20:36:51.615923+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-02-11T20_36_51_610Z-debug.log
2018-02-11T20:36:51.615844+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
Try executing 'heroku logs' command inside your project's root directory.

Use bower to install bootstrap 4

I'm trying to get into using my terminal on a mac. I installed npm sucessfully and when I type npm --version it gives me 2.14.12. With npm I installed bower and I think it worked. But I have two questions:
when I type bower -v it gives me this:
/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:56
throw err;
^
Error: EACCES: permission denied, open '/Users/philip/.config/configstore/bower- github.yml'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (evalmachine.<anonymous>:549:18)
at Object.fs.readFileSync (evalmachine.<anonymous>:397:15)
at Object.create.all.get (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:34:29)
at Object.Configstore (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:27:44)
at readCachedConfig (/usr/local/lib/node_modules/bower/lib/config.js:19:23)
at defaultConfig (/usr/local/lib/node_modules/bower/lib/config.js:11:12)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/lib/index.js:16:32)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
but when I type sudo bower -vit works and gives me 1.7.2 after I typed in my password. Why doesn't it work without sudo?
I wanted to install bootstrap 4 in a folder on my desktop so with cd I went to the directory and typed bower install bootstrap#v4.0.0-alpha.2 and it gives me this:
/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:56
throw err;
^
Error: EACCES: permission denied, open '/Users/philip/.config/configstore/bower-github.yml'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (evalmachine.<anonymous>:549:18)
at Object.fs.readFileSync (evalmachine.<anonymous>:397:15)
at Object.create.all.get (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:34:29)
at Object.Configstore (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:27:44)
at readCachedConfig (/usr/local/lib/node_modules/bower/lib/config.js:19:23)
at defaultConfig (/usr/local/lib/node_modules/bower/lib/config.js:11:12)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/lib/index.js:16:32)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
Can somebody tell me why? Thanks!
EDIT:
I'm that far now:
Philips-MacBook-Pro:test philip$ bower install bootstrap
bower bootstrap#* not-cached git://github.com/twbs/bootstrap.git#*
bower bootstrap#* resolve git://github.com/twbs/bootstrap.git#*
bower bootstrap#* ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/twbs/bootstrap.git", exit code of #69 Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Additional error details:
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
The reason you are getting the EACCESS error is without sudo is because you do not have permission to access those files.
To check the current permissions of a file/directory run:
ls -l <file or directory name>
at the terminal prompt.
You will see output similar to this:
drwxr--r-- 1 owner group...
for each listing.
The first character of that ouput represents the file type. In the example 'd' means the file listed is a directory. The second group of three characters describes the read ('r' in the example), write ('w') and execute ('x') permissions for the owner of the file.
The next three characters describe permissions for the group the file belongs to. In the example, you see 'r--'. This means the group that the file belongs to only has permission to read the file- no permission to write to (as indicated by the '-') or execute the file.
The final three characters describe the permissions for 'all users'. In the example, 'r--' indicates that all users have read-only access to the file.
This resource will help you understand *nix/OS X file permissions: http://www.comentum.com/unix-osx-permissions.html
In order to run those commands without sudo you will change the current permission settings to allow yourself read/write access to the files that are throwing EACCESS errors. This can be done through the GUI or with the chmod command at the terminal.
Running man chmod at the terminal brings up the man page (https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/chmod.1.html) for the chmod command.

"cannot find module" when installing npm modules on windows

I am new to NodeJS. I am trying to use npm on Windows 8.
I have installed using chocolatey, cinst nodejs.install (version 0.10.17). I installed as administrator (and would prefer to run npm as a normal user).
Node itself seems to be working, I can use the REPL to run simple programs.
If I try to install something using npm, I get cannot find module:
> node npm install express
module.js:340
throw err;
^
Error: Cannot find module 'C:\Users\Klas\Documents\My Dropbox\mina egna\tech\node\webserver\npm'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
I have read the answers on Nodejs cannot find installed module on Windows? but unfortunately it is still unclear to me what I have to do.
I have tried setting NODE_PATH:
In trying to follow this answer, I have tried setting it to C:\Users\Klas\AppData\Roaming\npm\node_modules (but I had to create both the npm and the subfolder node_modules myself)
I have tried creating a folder c:\node\node_module (according to this advice, even though the installation did not even create a c:\node folder) and setting it to that.
I have tried setting it to C:\Program Files\nodejs\node_modules\npm\node_modules (which did exist after installation)
I have also tried to create a node_modules folder below the current working directory. As I understand it that is where local npm will be installed?
None of these helped. So it seems to me that setting NODE_PATH is not the solution?
Using the -g flag makes no difference (I would prefer not to use it).
I get the same error both as normal user and as administrator (I would prefer to be a normal user).
I get the same error no matter where I execute the command, except when I do it in C:\Program Files\nodejs, where I get
basedir=`dirname "$0"`
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
Not using windows, but I'm pretty sure it's just npm install express on windows too.

Resources