Capistrano deploy fails due to missing manifest file when using assets prefix - ruby-on-rails-3

I've just set up a Capistrano deploy for our application and I keep running into this error:
* executing ["ls /path/to/app/shared/assets/manifest*"]
servers: ["web03"]
[web03] executing command
[err :: web03] ls: /path/to/app/shared/assets/manifest*
[err :: web03] : No such file or directory
If I manually create a manifest file with touch /path/to/app/shared/assets/manifest.yml, the deploy script works fine. However, this feels all sorts of sketchy.
I've googled the heck out of this and the most I can gather is that the manifest file it's looking for is a product of the asset pipeline. I checked and I do, in fact, have the pipeline enabled (config.assets.enabled = true), so I'm at a loss.
Could someone please help me understand 1) what this manifest file is and how it's created; and 2) why isn't one being created for my application?
Update: I think I'm closing in on the answer and I think it has something to do with this line:
config.assets.prefix = "/some_other_path"
We needed to rename the "asset" path because we have Asset objects in our system and I'm guessing Cap might be getting confused because of it. Any suggestions?

My suspicion was right: this was a problem with the renamed asset directory. Cap didn't know to look in public/some_other_path instead of public/assets.
In other words, because this line is in my application.rb:
config.assets.prefix = "some_other_path"
I had to add this line to my deploy.rb:
set :assets_prefix, "some_other_path"
Then, Cap knows where to look for a manifest, copies it into shared/assets, and finishes correctly.
It'd be handy to have the deploy.rb reference the config variable instead of having to hard-code the path a second time, but that's outside the scope of this question.

if you configure with the aws, here it should be...
appname/config/environments/production.rb
config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
config.assets.prefix = "/#{ENV['APP_NAME']}/assets"
appname/config/deploy.rb
...
set :keep_releases, 5
set :assets_prefix, ->{ "#{fetch(:application)}/assets" }
set :whenever_identifier, -> { "#{fetch(:application)}_#{fetch(:stage)}" }
...

Related

Laravel 5.8 , artisan commands error : Failed to parse dotenv file due to an invalid name

This problem only happens with Laravel 5.8 on my shared hosting.
It is working fine in my shared hosting with Laravel 5.7.
It is working fine in my local environment with Laravel 5.8.
the problem is:
every time I run php artisan commands (on my shared hosting with Laravel 5.8 only) I got this error
The environment file is invalid! Failed to parse dotenv file due to an invalid name.
Failed at [APP_NAME].
my .env first line is : APP_NAME=rased
Also my site after updating to Laravel 5.8 is becoming a white blank page!
This is a general error related to parsing the .env file.
You'll see this is indicated in the error e.g.
The environment file is invalid!
Failed to parse dotenv file due to unexpected whitespace.
Failed at [This will fail].
In this example it was caused by having unescaped whitespace in the APP_NAME field i.e.
APP_NAME=This will fail
To fix, escape with quotes e.g.
APP_NAME="This is better"
This is general Error when we change our app name. To remove this error just do this.
APP_NAME=My Project Name
to this
APP_NAME="My Project Name"
You just need to add "" course around name.
Thanks
I found the cause of this problem.
It was because of line separator in .env file !
It must be CRLF not LF
My .env file was LF
see the screenshot to understand the solution
I received a similar error while upgrading from Laravel 5.5 to Laravel 5.8.
The environment file is invalid! Failed to parse dotenv file due to an
invalid name. Failed at [//APP_ENV].
5.5 would accept C style comments on APP_ENV:
// env file setup for production environment
//APP_ENV = production
//APP_DEBUG = false
// env file setup for local environment
APP_ENV = local
APP_DEBUG = true
While 5.8 will not. # works for comments:
# env file setup for production environment
#APP_ENV = production
#APP_DEBUG = false
# env file setup for local environment
APP_ENV=local
APP_DEBUG=true
I had tried removing the spaces as a brand new 5.8 application installs without spaces in these definitions. That didn't fix it.
Curiously I still have C style comments other places in the file, so only for APP_ENV?
I changed the encoding of .env and it was solved.
UFT-8 without BOM
Thanks
I recently ran into this same problem on my app for Laravel 6.12.0.
I was able to resolve this issue by adding a blank new line/space at the top of the .env file.
Example .env file:
[add a new line here]
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
I had exactly the same problem, but a different solution. CRLF made no difference.
This was driving me nuts, and I read somewhere that C style comments were no longer supported. My env file didn't contain any, but in desperation I added the following line to the top of the file:
# getting tiresome.
I don't think the wording is important, but the key thing was there was a comment.
After that, it worked. I don't know why, but it did.
Fast forward a few months, and the problem returned the next time I have to upgrade Laravel. This was kind of weird as the file was the same. This time I had to make sure I saved the file as UTF-8 without BOM.
I have added course "" around the DB_DATABASE path.
MAIL_FROM_NAME=Account confirmation
i was just making spaces between the two words
Just try to avoid it like : Account_confirmation
MAIL_FROM_NAME=Account_confirmation (correct)
In my case, I had an extra line that shouldn't be there.
Header set X-Frame-Options SAMEORIGIN Removed this and IT WORKED
I discover that if you declare the APP_NAME in quotes in the .env file, It will allow spaces in the app name but make sure you restart the server using the command (php artisan serve)
For e.g: APP_NAME='Laravel Login'
That works for me.
delete the .env file and recreate another with the same content
In case anybody else gets here and hasn't solved their problem. I came across this issue and found that it was due to using a hyphen to separate the environment variable name.
NOM-OPEN="2020/01/24"
This was okay up to Laravel 5.7 but fell over for 5.8. To solve it change the hyphen to an underscore.
NOM_OPEN="2020/01/24"
Don't forget to update all references to the variable!

Geb/Spock Error- No reports dir has been configured, you need to set in the config file or via the build adapter

I have trouble running my functional test from IntelliJ IDE. When I run the functional test, I got the following error message:
java.lang.IllegalStateException: No reports dir has been configured, you need to set in the config file or via the build adapter.
at geb.Browser.getReportGroupDir(Browser.groovy:899)
at geb.Browser.cleanReportGroupDir(Browser.groovy:932)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:56)
at geb.spock.GebReportingSpec.setupSpec(GebReportingSpec.groovy:37)
Based on my research, all I need to do is to add the following code in GebConfig.groovy:
reportsDir = new File("target/runtime_reports_dir")
I added the line to GebConfig.groovy and rebuild the project, but still running into the same issue. Is there any other fix to this error?
Adding reportsDir = 'target/geb-reports' to your GebConfig shoud fix this, can you show me your GebConfig file?
There is also another fix for it, your test class extends GebReportingSpec, you can chage it to GebSpec and it should also work.
I had this same issue, while having the reportsDir correctly configured in the GebConfig
Adding the resources folder (where my GebConfig is located) as "Test Sources Root" did the trick for me
To mark the folder as "Test Sources Root":
Right click in the folder
Mark Directory as
Test Sources Root
Happy testing!

Safari Push Notifications - Verifying hashes in manifest.json failed even though correct

I have created a push package with the appropriate files as per the Apple spec for APNS. This manifest file represents all of the files that are present:
{
"icon.iconset/icon_128x128.png": "78609fcff69688f969a38f957ac2f10fc79d6732",
"icon.iconset/icon_128x128#2x.png": "78609fcff69688f969a38f957ac2f10fc79d6732",
"icon.iconset/icon_16x16.png": "d348589e2cf37d8f23940f8545afe75a2e98b4ac",
"icon.iconset/icon_16x16#2x.png": "d348589e2cf37d8f23940f8545afe75a2e98b4ac",
"icon.iconset/icon_32x32.png": "e4418a1c5f2ecfbb702961515aaa65d5449b1c53",
"icon.iconset/icon_32x32#2x.png": "e4418a1c5f2ecfbb702961515aaa65d5449b1c53",
"website.json": "45be9c4a6f1bf96e27a9eecab219304b35c5ac24"
}
I have manually checked the sha1 values on the CLI and they are all correct, along with the file locations. And yet I still get this error back from Safari each time I try to get permission:
{ '{"logs":': { '"Verifying hashes in manifest.json failed"]': '' } }
Which is not valid JSON either. Any ideas why this would be failing?
I recently implemented push notifications through pushwoosh. They automatically created the package for me and I checked how they done it. The only difference between mine manifest file and your is a back slash before the normal slash. Maybe it could do the difference for you. Copy and paste this code in your manifest (I have already added your SHA1 values):
{"icon.iconset\/icon_16x16.png":"d348589e2cf37d8f23940f8545afe75a2e98b4ac","icon.iconset\/icon_16x16#2x.png":"d348589e2cf37d8f23940f8545afe75a2e98b4ac","icon.iconset\/icon_32x32.png":"e4418a1c5f2ecfbb702961515aaa65d5449b1c53","icon.iconset\/icon_32x32#2x.png":"e4418a1c5f2ecfbb702961515aaa65d5449b1c53","icon.iconset\/icon_128x128.png":"78609fcff69688f969a38f957ac2f10fc79d6732","icon.iconset\/icon_128x128#2x.png":"78609fcff69688f969a38f957ac2f10fc79d6732","website.json":"45be9c4a6f1bf96e27a9eecab219304b35c5ac24"}
I created a small ruby script for generating these manifests based on the code in https://github.com/SymmetricInfinity/push_package/blob/master/lib/push_package.rb.
Copy the script into a directory containing an icon.iconset directory and your website.json. Then you can run ruby gen_manifest.rb inside that directory and the script will write the manifest.json. At the very least it may be a sanity check to see that everything is correct. The script is here: https://gist.github.com/adamvduke/7934457
If you don't have any ruby experience, comment back and I can walk you through it.

Hadoop configurations seem not to be read

Every time when I try to start my mapreduce application (in standalone Hadoop), it tries to put stuff in the tmp directory, which it can't:
Exception in thread "main" java.io.IOException: Failed to set permissions of path: \tmp\hadoop-username\mapred\staging\username-1524148556\.staging to 0700
It ties to use an invalid path (slashes should be the other way around for cygwin).
I set hadoop.tmp.dir in core-site.xml (in the conf folder of Hadoop), but it seems that the config file is never read (if I put syntax errors in the file, it makes no difference). I added:
--config /home/username/hadoop-1.0.1/conf
To the command, but no difference. I also tried:
export HADOOP_CONF_DIR=/home/username/hadoop-1.0.1/conf
but also that does not seem to have an effect....
Any pointers on why the configs would not be read, or what else I am failing to see here?
Thanks!
It's not that the slashes are inverted, it's that /tmp is a cygwin path which actually maps to /cygwin/tmp or c:\cygwin\tmp. since hadoop is java and doesn't know about cygwin mappings, it takes /tmp to mean c:\tmp.
there's an awful lot of stuff to patch if you want to get 1.0.1 running on cygwin.
see: http://en.wikisource.org/wiki/User:Fkorning/Code/Hadoop-on-Cygwin
I found the following link useful, it seems that the problem stands with newer version of Hadoop. I'm using version 1.0.4 and I'm still facing this problem.
http://comments.gmane.org/gmane.comp.jakarta.lucene.hadoop.user/25837
UPDATED: in Mahout 0.7 and for the ones who use the "Mahoot in Action" book example, you shoud change the example code as follows:
File outFile = new File("output");
if (!outFile.exists()) {
outFile.mkdir();
}
Path output = new Path("output");
HadoopUtil.delete(conf, output);
KMeansDriver.run(conf, new Path("testdata/points"), new Path("testdata/clusters"),
output, new EuclideanDistanceMeasure(), 0.001, 10,
true, 0.1, true);

Multiple public folders, single rails installation

I have a rails application I would like to use for multiple sites, each with different designs.
I would like to change the rails installation /public directory to something else (dynamically eventually). However, I have run into a problem (bug?) changing directories...
In my application.rb file I change the paths.public path to something other than "public" (let's say "site_one"). Here is the code:
puts paths.public.paths
paths.public = "site_one"
puts paths.public.paths
The two "puts" commands are for debugging. Now run "rails s" and you will see:
/home/macklin/app/public
/home/macklin/app/site_one
This verifies the path is changed correctly. However, shortly afterward, rails throws the following error (let me know if you need the full trace):
Exiting
/usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/paths.rb:16:in `method_missing': undefined method `javascripts' for #<Rails::Paths::Path:0x7f422bd76f58> (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_controller/railtie.rb:47
My guess is it cannot find the javascripts directory even though it is clearly sitting in the "site_one" folder.
Does anyone know why I am getting this?
I know this question is pretty old, but I think I found an answer for this in Rails 4.2.
You just simply have to put this line in your config/application.rb:
middleware.use ::ActionDispatch::Static, "#{Rails.root}/another_public_folder_name", index: 'index', headers: config.static_cache_control
This makes all files in /another_public_folder_name to be served by Rails.
This is the way Rails use to setup the standard /public folder. I found it checking the sources:
https://github.com/rails/rails/blob/52ce6ece8c8f74064bb64e0a0b1ddd83092718e1/railties/lib/rails/application/default_middleware_stack.rb#L24
Duh. Just add 2 more rules for stylesheets and javascripts (I guess they get wiped when you change the parent path)
paths.public.stylesheets = "site_one/stylesheets"
paths.public.javascripts = "site_one/javascripts"