Rails: moving development environment from windows(mingw32) to OS X mountain lion - postgresql

I have a rails 3.2.3 application which I was developing on my windows machine using git_bash as cli and mingw32 as environment (installed this env using railsinstaller)and postgres as db.
But there were some problems with rmagick and couldn't use it, although minimagick was working as expected.
Now, I am going to move application to my new mac machine running OS X mountain lion.
I have installed rails 3.2.8 and ruby on OS X using rvm. what do I need to do to update my application to rails 3.2.8 and setup db and other gems, should I delete or not delete gemfile.lock and what gems I need to remove or add or change version no. etc.
I am new to rails, please help
thanks!
Should I install postgres using homebrew or download from http://www.postgresql.org/download/macosx/
which is a preffered way of installing postgres, pros and cons of these methods.

As long as you don't have any Windows/machine-specific code in your app, you'll just need to do bundle install.
Regarding Postgres, it doesn't matter where you get it from, as long as it's on your $PATH. If you're already using Homebrew, then it makes sense to just do brew install postgres.

Gemfile.lock gives A list of gems used to ensure that all copies of the app use the same gem versions.
since I'm the only one working on this app and it's not yet in production. So, for me it makes more sense that I nuke Gemfile.lock and specify updated versions of gems I want now.
Things I did
Copied my application directory from my windows machine after cleaning some data in my tmp/ directory( tmp/ directory had 100M of data).
Installed imagemagick using brew install imagemagick
Installed postgresql using brew install postgresql
Generated a sample app using rails new blog -d postgresql
Changed database.yml file according to postgresql, as it required my mac user to be the username.
run sample blog app, and it was working fine. created a scaffolding and entered data and everything was working.
copied content of Gemfile.lock from blog application and pasted in my application's Gemfile.lock
changed version of rails in my Gemfile from 3.2.3 to latest version 3.2.8. changed version of some other gems.Replaced 'minimagick' with 'rmagick'. (I had problem with installing rmagick gem on windows, minimagick gem somehow worked on windows with older version of imagemagick).
Changed database.yml.
run rake db:create:all to create all the db.
run rake db:migrate
Run bundle and it installed all the dependecies.
run rails s
Everything is working fine now :)

Related

Will Homebrew install of mongodb overwrite existing databases?

I want to reinstall mongodb on my mac using the following commands:
brew tap mongodb/brew
brew install mongodb-community
If I do this, will I lose the current databases in my existing mongodb install?
Edit
To clarify, the previous installation was done via HomeBrew as well.
It depends on where your existing database files are stored, whether mongo was installed via Homebrew previously, and if so, which version was installed.
Homebrew will install mongodb into /usr/local/Cellar/mongodb-community/{version} (4.4.0 as of this writing) and symlink the binaries into /usr/local/bin. It will not modify an installation performed by another means and any existing databases will be untouched as long as they're not in the same path as this installation. You would be able to load them with the Homebrew version with no issues.
You will need to consider your $PATH if you plan to leave both mongodb versions installed - if the Homebrew path (/usr/local/bin) is after the path of your current installation then the old binary will run. Homebrew usually takes care of this for you, but something to watch out for if you have any strange behaviour. Check the location of your current binaries by running which mongod.
To stay on the safe side, you should make a copy of your existing data files before you [re,un]install.

Upgrading sqlite3 on Centos 7

Does anyone know how to upgrade sqlite3 on Centos7. The repos only have up to version 3.7.
I downloaded the source code and compiled. Replaced binaries. If I type sqlite/sqlite3 --version then it's 3.31.
If I run rails then it's stuck at 3.7.
DNF is stuck on 3.7 too.
I read that Centos7 stays at this version. There's no easy upgrade path to Centos8 without reinstall so trying to avoid that.
Uninstall the package from Centos. Then, do a normal source install of sqlite afterwards.

Bundle only supports platforms x64-mingw32 but local is x86_64-linux

I developed my Rails Application in a Windows environment and I am trying to deploy into Linux Ubuntu 16.04. I am stumbling upon this error:
Your bundle only supports platforms ["x64-mingw32"] but your local
platforms are ["ruby", "x86_64-linux"] and there's no compatible match
between those two lists.
I think the problem is with gemfile.lock . in addition to seeing strings with 'x64-mingw32' for each gem; I find that there is also this:
PLATFORMS
x64-mingw32
How do I make my application run in a Linux 16.04 LTS Environment?
Your Gemfile.lock is restricting the platform your app can run on.
Deploying the app into Linux without the .lock file should resolve your issue.
If you have any Windows-specific gems in your Gemfile, its better to move them to a dedicated block:
# Gemfile
platform :mswin, :mingw, :x64_mingw do
gem "tzinfo-data"
gem "win32_api"
end
Capistrano requires the Gemfile.lock file for deployment. Bundler is the one that is causing this but according to their Github it is intented behaviour to make your app compatible with different platforms.
In order for this to work - as of 1.13, you could run bundle lock --add-platform ruby on Windows to add the ruby platform to your lockfile ahead of time.
Github Issue

How to fix pg_dump version mismatch errors?

When trying to get local data to Heroku, I am encountering a version mismatch between two different versions of pg_dump.
Specifically, I am getting this message:
pg_dump: server version: 9.2.2; pg_dump version: 9.1.4
pg_dump: aborting because of server version mismatch
I have found others with this problem, but do not know enough to implement the proposed solutions. (I am new to Ruby on Rails, PostgreSQL, Heroku, and the Mac! Very much at the stage of playing around the picking things up as I go.)
I was thinking I might simplify my life if I uninstalled all PostgreSQL on my local machine and started again with a clean install of PostgreSQL 9.2.2 from http://postgresapp.com/, but I don't know how to go about doing the uninstall.
I'm running Mac OS X Mountain Lion 10.8.2.
OS X 10.8 comes with pg_dump version 9.1.4 in the /usr/bin directory, along with psql and other programs that are client-side PostgreSQL tools. It does not mean that PostgreSQL as a server is installed (unless you have OS X Server Edition).
So you don't have to uninstall PostgreSQL because it's not installed and it's better not to remove these postgres client tools in /usr/bin because they belong to the system as shipped by Apple. They just need to be side-stepped.
The package provided by postgres.app comprises both the PostgreSQL server and the client-side tools of the same version as this server. These tools get installed in /Applications/Postgres.app/Contents/MacOS/bin
To use these instead of the 9.1 ones from Apple when you work in a Terminal, postgres.app documentation says to do:
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
and put it in your .profile file.
Once you have done that and you run pg_dump, you should no longer get the error that's it's the wrong version, because it would be the one that ships with postgres.app (currently 9.2.2).
I have this setup and it works OK for me.
If you only need to upgrade your pg_dump to the latest version and you have homebrew and mac, if the app has the latest version and your local pg doesn't:
brew upgrade postgresql
If you're using postgresapp 9.3.x, the path is different. The following worked for me (courtesy of http://sigmyers.com/blog/2013/3/12/postgres-pgdump-version-mismatch-error-postgresapp-postgresappcom)
export PG_BIN_PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin/"
PATH=$PG_BIN_PATH:$PATH
Check here for the latest path: http://postgresapp.com/documentation/cli-tools.html
I'm running Mountain Lion Server. My PostgeSQL server is at version 9.2.1 and the default tools are at 9.1.5.
I had to use:
PATH="/Applications/Server.app/Contents/ServerRoot/usr/bin:$PATH"
to make it work.
Yep, sometimes if you run Postgres.app this may happen after upgrade. Make sure you restart your Postgres.app - it will update your PATH.
In my case I have postgresql installed via homebrew and the executables are here: /usr/local/opt/postgresql#9.6/bin
Or you copy the dump and restore executions to the /Applications/Postgres.app/Contents/SharedSupport folder
or in PdAgmin you point the PG bin Path (in properties -> binary Path) to the path of the executables of your postgre

Installing postgis in mac

I am trying to install postgis in mac. But I am not sure if I should compile it from the source code or install the binary. When I tried to install the binary it says that I need to install postgresql 9.1 which I already have. What should I do? Are there any clear instructions for installing in mac
When I run into trouble I usually install from source. This gives the configuration and compilers a better chance to tailor everything to your computer. You must have the development libraries for postgresql installed however to make this work with postgis.