Clearing All Assets In GitLab - ruby-on-rails

I want to use custom logo-white, logo-black, and favicon in my company installation of GitLab.
I've Googled my butt off and tried eveything I can find to clear these damn images and nothing seems to work.
Here's the only process that seems to run successfully, yet it does not remove the images:
bundle exec rake cache:clear RAILS_ENV=production
service gitlab stop
redis-cli FLUSHALL
bundle exec rake assets:precompile RAILS_ENV=production
service gitlab start
Then I clear my browser cache and go to the domain and there are the same damn images again!
I even deleted all the logo and favicon files I could find completely from the application, and yet somehow they are still there.
HELP!

There's a rake task assets:clean since version 6.0. So run bundle exec rake assets:clean RAILS_ENV=production from the command line and it will remove the assets.
After you nuke them, you'll probably want to run bundle exec rake assets:precompile RAILS_ENV=production to rebuild them.

I was able to combine some of the info here, and successfully replaced the logo using the following steps (note that some commands are slightly different using the latest version of gitlab, 7.11.4, on CentOS 7, so I am adding this as an answer in the hopes that it will be helpful to users with the new version):
Replace the appropriate images in /opt/gitlab/embedded/service/gitlab-rails/app/assets/images
Stop gitlab using sudo gitlab-ctl stop
Refresh the rails cache sudo gitlab-rake assets:clean RAILS_ENV=production followed by sudo gitlab-rake assets:precompile RAILS_ENV=production
Start gitlab using sudo gitlab-ctl start
For some reason I was getting permission errors in the precompile step. This was solved by changing the write permissions to /opt/gitlab/embedded/service/gitlab-rails/public/assets/ to be globally writable (a+w). It seems that gitlab-rake runs as the git user, even though I used sudo. So, after the steps above, I also changed the owner to root (sudo chown -R root:root /opt/gitlab/embedded/service/gitlab-rails/public/assets), and the permissions back using a-w.
I assume that upgrading gitlab will revert the logo back to the original one, but I haven't tried that yet.

I found the answer for anyone looking.
You also have to replace the images in
app/assets/images/

Related

Is there a way to connect to a Rails app's console on a linux server?

I have deployed a rails application using capistrano on a linux server and it is running without any problems. When I connect to my remote server via ssh, the folder structure of my app is quite different from what I have on my local machine. I would like to go to project root and say rails console so that I can have access to the console of my application. Is there a way to achieve this?
When I go to ~MyApp/ folder and run rails console it says command rails not found. I think that is probably because the app is running in another folder.
bundle exec to the rescue inside of project folded:
$ RAILS_ENV=production bundle exec rails console
If you've installed with rbenv it could be that you are defaulting to the wrong Ruby version. So you can run rbenv exec to get it to run on the right version, along with bundle exec to run the right version of Rails
So try running this:
rbenv exec bundle exec rails console
To sum up for anyone having the same problem in the future,
I went to MyApp/releases/2020331231231231 which is the latest release of my app and there I used this command RAILS_ENV=production bundle exec rails console and I was able to do whatever I wanted to do in the console.
First you need to move inside the folder where the code is.
Check Capistrano config if deploy_to is defined. (If it's not it should be set to /var/www/#{application}/ by default read here)
Since Capistrano keep older versions of your app go to the current folder which is a symlink of the latest deployed version.
And run ENVIRONMENT=production bundle exec rails c or ENVIRONMENT=production bin/rails c. If doesn't work try with rbenv ENVIRONMENT=production rbenv exec bundle exec rails c

bundle exec not working in Windows

I am following the Redmine Install Tutorial
on step 5 it says
Step 5 - Session store secret generation
This step generates a random key used by Rails to encode cookies storing session data thus preventing their tampering.
Generating a new secret token invalidates all existing sessions after restart.
bundle exec rake generate_secret_token
I'm on Windows 10. When I try to do bundle exec in CMD, I get cannot find the path specified. For whatever reason I cannot find any reference to this problem (perhaps I'm not searching for the right terms). I can't imagine I'm the first to experience this but in any case, how can I resolve it? I can check ruby version, gem version, and rails version just fine. I've been able to do steps 1-4 fine so I don't get why I can't run bundle exec. I suppose this is implied but I can't do step 6 either.
Do you have rake rubygem installed? Try to run this in CMD:
gem install rake
Then run the command again:
bundle exec rake generate_secret_token
I'm looking at this: source

How come rake needs bundle exec, but rails doesn't?

I appreciate all the answers out there as to what bundle exec does, which is that it runs the following commands in the context of the Gemfile bundle. But why doesn't "rails server" need bundle exec? Seems like it should still apply.
The rails command runs from the executable inside the script folder. If you remove this folder, you can see that rails commands stop working. rake however runs differently.

rails assest:precomplie , when load file not correct

I have web RoR, I ran assets:precomplie, and i got file
**/application-dfaaca6b25e0d101d80f81c5cb194f6d39d331886613c0a392283b01b9911cb0.css**
but my web was loaded another file
**application.self-a429e1a197d1ad3e5a775f50a60fd344db3ba490db151ab8c7494a78cba792a2.css**.
i don't know reason. Anybody, can help me? Thanks a lot
I got the same questions. then finally I find the answer:
when you process assets:precomplie, you must specify the env as you run rails, because in different enviroments, the assets version is not same!
when you run rails in development env as rails s, you should process as rake assets:precomplie or assets:precomplie RAILS_ENV=development
when you run rails in production env as rails s -e p, you should process as rake assets:precomplie RAILS_ENV=production
hope this helps!
Solution:
Deploy your application again
if still not solved
SSH into the system
delete the file your_app/manifest_backup
$ bundle exec rake assets:clear
$ bundle exec rake assets:precompile RAILS_ENV=production
restart the webserver ( for Nginx /etc/init.d/nginx restart or $ sudo service nginx restart )
if still not solved deploy your app again
For more info see my blog
https://cbabhusal.wordpress.com/2015/07/20/ruby-on-rails-production-staging-when-asset-path-is-outdated/

root cron not running

I have a root user cron setup to run every one hour. I manually ran the rake task and it ran successfully as root user. But when i added this rake task as a cron, it doesn't work, I checked the /var/log/syslog and it seems to have the run the cron and also I redirected the stdout and stderr and examined the file, but the file seems to be empty. My guess is that there is an issue with running the cron as a root user. Has anyone face this problem before.?
Quick Update
In the stdout/stderr logs I'm getting a missing gems, I'm using RVM and I have installed my gems both globally and the gemset which I'm currently using.
Sounds like maybe rake can't be found in the default cron environment. Try first changing to the appropriate directory, and then this below, which will try to locate rake and then run it:
0 */1 * * * cd /app/directory; /usr/bin/env rake <task>
Also try adding setting a PATH that includes the path to rvm binaries:
PATH=/usr/local/rvm/bin;/usr/local/bin:/usr/bin:/bin
(Substitute /usr/local/rvm/bin with the path to rvm on your system)

Resources